@swell/cli 2.9.4 → 2.9.6

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 (82) hide show
  1. package/dist/app-command.d.ts +2 -3
  2. package/dist/app-command.js +3 -6
  3. package/dist/commands/app/dev.d.ts +2 -2
  4. package/dist/commands/app/dev.js +49 -33
  5. package/dist/commands/app/frontend/dev.js +12 -6
  6. package/dist/commands/app/push.d.ts +1 -0
  7. package/dist/commands/app/push.js +3 -3
  8. package/dist/commands/app/release.js +2 -2
  9. package/dist/commands/create/app.d.ts +1 -1
  10. package/dist/commands/create/app.js +1 -1
  11. package/dist/commands/create/frontend.js +3 -3
  12. package/dist/commands/create/tests.js +10 -8
  13. package/dist/commands/inspect/extensions.js +4 -4
  14. package/dist/commands/schema.js +21 -18
  15. package/dist/commands/theme/dev.js +5 -5
  16. package/dist/commands/theme/push.d.ts +1 -0
  17. package/dist/commands/theme/push.js +3 -3
  18. package/dist/create-app-command.js +2 -2
  19. package/dist/create-config-command.d.ts +1 -1
  20. package/dist/create-config-command.js +3 -3
  21. package/dist/help/custom-help.d.ts +1 -1
  22. package/dist/help/types.d.ts +1 -1
  23. package/dist/lib/api.d.ts +1 -0
  24. package/dist/lib/api.js +1 -1
  25. package/dist/lib/app-config.d.ts +13 -8
  26. package/dist/lib/app-config.js +25 -23
  27. package/dist/lib/apps/app-config.d.ts +5 -5
  28. package/dist/lib/apps/app-config.js +53 -37
  29. package/dist/lib/apps/index.d.ts +15 -14
  30. package/dist/lib/apps/index.js +40 -23
  31. package/dist/lib/apps/paths.d.ts +1 -1
  32. package/dist/lib/apps/paths.js +3 -3
  33. package/dist/lib/bundle.js +26 -17
  34. package/dist/lib/config.d.ts +8 -8
  35. package/dist/lib/config.js +8 -10
  36. package/dist/lib/constants.d.ts +9 -9
  37. package/dist/lib/create/content.d.ts +6 -6
  38. package/dist/lib/create/content.js +7 -8
  39. package/dist/lib/create/function.d.ts +5 -6
  40. package/dist/lib/create/function.js +7 -8
  41. package/dist/lib/create/index.d.ts +8 -9
  42. package/dist/lib/create/index.js +7 -8
  43. package/dist/lib/create/model.d.ts +4 -4
  44. package/dist/lib/create/model.js +4 -5
  45. package/dist/lib/create/notification.d.ts +2 -3
  46. package/dist/lib/create/setting.d.ts +4 -4
  47. package/dist/lib/create/setting.js +3 -4
  48. package/dist/lib/create/tests/templates/mock-request.js +30 -0
  49. package/dist/lib/create/tests/templates/setup-globals.js +35 -0
  50. package/dist/lib/create/tests/types.d.ts +3 -4
  51. package/dist/lib/create/tests.d.ts +1 -2
  52. package/dist/lib/create/tests.js +12 -13
  53. package/dist/lib/create/webhook.d.ts +6 -6
  54. package/dist/lib/create/webhook.js +15 -10
  55. package/dist/lib/function-source-analysis.js +3 -3
  56. package/dist/lib/info.d.ts +1 -1
  57. package/dist/lib/logs/index.d.ts +1 -0
  58. package/dist/lib/logs/line-output.d.ts +1 -0
  59. package/dist/lib/logs/line-output.js +12 -4
  60. package/dist/lib/logs/output.d.ts +1 -0
  61. package/dist/lib/logs/table-output.d.ts +1 -0
  62. package/dist/lib/logs/table-output.js +8 -5
  63. package/dist/lib/package-manager.d.ts +5 -5
  64. package/dist/lib/package-manager.js +9 -7
  65. package/dist/lib/proxy.js +4 -3
  66. package/dist/lib/sessions.d.ts +1 -2
  67. package/dist/lib/sessions.js +1 -2
  68. package/dist/lib/stores.d.ts +6 -6
  69. package/dist/lib/stores.js +5 -6
  70. package/dist/lib/swell-function-wrapper.d.ts +1 -193
  71. package/dist/lib/swell-function-wrapper.js +24 -1
  72. package/dist/lib/theme-sync.js +0 -5
  73. package/dist/push-app-command.d.ts +7 -6
  74. package/dist/push-app-command.js +35 -37
  75. package/dist/remote-app-command.d.ts +6 -4
  76. package/dist/remote-app-command.js +39 -25
  77. package/dist/swell-api-command.d.ts +1 -0
  78. package/dist/swell-api-command.js +3 -3
  79. package/dist/types/index.d.ts +94 -0
  80. package/dist/types/index.js +4 -0
  81. package/oclif.manifest.json +1 -1
  82. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
- import * as fs from 'node:fs';
1
+ import * as fs from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
- import { filePathExists, writeFile } from '../apps/index.js';
3
+ import { filePathExistsAsync, writeFile } from '../apps/index.js';
4
4
  import { envDtsTemplate, integrationTestTemplate, mockRequestTemplate, setupGlobalsTemplate, swellClientTemplate, tsconfigTemplate, unitTestTemplate, vitestConfigTemplate, } from './tests/templates/index.js';
5
5
  const TEST_DEV_DEPENDENCIES = {
6
6
  '@cloudflare/vitest-pool-workers': 'latest',
@@ -8,15 +8,15 @@ const TEST_DEV_DEPENDENCIES = {
8
8
  '@swell/app-types': 'latest',
9
9
  };
10
10
  async function writeTextFile(filePath, contents, overwrite) {
11
- if (!overwrite && filePathExists(filePath)) {
11
+ if (!overwrite && (await filePathExistsAsync(filePath))) {
12
12
  return { created: false, skipped: true };
13
13
  }
14
14
  await writeFile(filePath, contents);
15
15
  return { created: true, skipped: false };
16
16
  }
17
- function updatePackageJson(appPath) {
17
+ async function updatePackageJson(appPath) {
18
18
  const pkgPath = path.join(appPath, 'package.json');
19
- if (!filePathExists(pkgPath)) {
19
+ if (!(await filePathExistsAsync(pkgPath))) {
20
20
  return {
21
21
  updated: false,
22
22
  warning: 'package.json not found. Run `npm init` first.',
@@ -24,7 +24,7 @@ function updatePackageJson(appPath) {
24
24
  }
25
25
  let pkgRaw;
26
26
  try {
27
- pkgRaw = fs.readFileSync(pkgPath, 'utf8');
27
+ pkgRaw = await fs.readFile(pkgPath, 'utf8');
28
28
  }
29
29
  catch (error) {
30
30
  return {
@@ -57,7 +57,7 @@ function updatePackageJson(appPath) {
57
57
  pkg.scripts = scripts;
58
58
  try {
59
59
  const next = `${JSON.stringify(pkg, null, 2)}\n`;
60
- fs.writeFileSync(pkgPath, next, 'utf8');
60
+ await fs.writeFile(pkgPath, next, 'utf8');
61
61
  return { updated: true };
62
62
  }
63
63
  catch (error) {
@@ -67,15 +67,15 @@ function updatePackageJson(appPath) {
67
67
  };
68
68
  }
69
69
  }
70
- function validatePrerequisites(appPath) {
70
+ async function validatePrerequisites(appPath) {
71
71
  const warnings = [];
72
72
  const tsconfigPath = path.join(appPath, 'tsconfig.json');
73
- if (!filePathExists(tsconfigPath)) {
73
+ if (!(await filePathExistsAsync(tsconfigPath))) {
74
74
  warnings.push('tsconfig.json not found. test/tsconfig.json extends it; create one or tests may not compile.');
75
75
  }
76
76
  return warnings;
77
77
  }
78
- async function createTestsScaffold(options) {
78
+ export async function createTestsScaffold(options) {
79
79
  const { appPath, appId, overwrite } = options;
80
80
  const result = {
81
81
  createdFiles: [],
@@ -83,7 +83,7 @@ async function createTestsScaffold(options) {
83
83
  packageJsonUpdated: false,
84
84
  warnings: [],
85
85
  };
86
- const prereqWarnings = validatePrerequisites(appPath);
86
+ const prereqWarnings = await validatePrerequisites(appPath);
87
87
  result.warnings.push(...prereqWarnings);
88
88
  const trackFile = async (relativePath, contents) => {
89
89
  const fullPath = path.join(appPath, relativePath);
@@ -103,11 +103,10 @@ async function createTestsScaffold(options) {
103
103
  await trackFile('test/helpers/mock-request.ts', mockRequestTemplate({ appId }));
104
104
  await trackFile('test/unit/example.test.ts', unitTestTemplate());
105
105
  await trackFile('test/integration/example.test.ts', integrationTestTemplate());
106
- const pkgResult = updatePackageJson(appPath);
106
+ const pkgResult = await updatePackageJson(appPath);
107
107
  result.packageJsonUpdated = pkgResult.updated;
108
108
  if (pkgResult.warning) {
109
109
  result.warnings.push(pkgResult.warning);
110
110
  }
111
111
  return result;
112
112
  }
113
- export { createTestsScaffold };
@@ -1,4 +1,4 @@
1
- interface CreateWebhookFileBody {
1
+ export interface CreateWebhookFileBody {
2
2
  $schema: string;
3
3
  description?: string;
4
4
  enabled?: boolean;
@@ -13,20 +13,20 @@ type ErrorHandler = (msg: string, options: {
13
13
  * Input: "payment.succeeded,payment.failed"
14
14
  * Output: ["payment.succeeded", "payment.failed"]
15
15
  */
16
- declare const parseEvents: (eventsInput: string) => string[];
16
+ export declare function parseEvents(eventsInput: string): string[];
17
17
  /**
18
18
  * Validate event format (model.action pattern)
19
19
  * Valid: "product.created", "payment.succeeded"
20
20
  * Invalid: "product", "created", "", ".created", "product."
21
21
  */
22
- declare const validateEventFormat: (events: string[], onError: ErrorHandler) => void;
22
+ export declare function validateEventFormat(events: string[], onError: ErrorHandler): void;
23
23
  /**
24
24
  * Validate URL format (basic check for protocol)
25
25
  */
26
- declare const validateUrl: (url: string, onError: ErrorHandler) => void;
26
+ export declare function validateUrl(url: string, onError: ErrorHandler): void;
27
27
  /**
28
28
  * Convert name to webhook label
29
29
  * "payment-handler" => "Payment Handler"
30
30
  */
31
- declare const toWebhookLabel: (value: string) => string;
32
- export { CreateWebhookFileBody, parseEvents, toWebhookLabel, validateEventFormat, validateUrl, };
31
+ export declare const toWebhookLabel: (value: string) => string;
32
+ export {};
@@ -4,7 +4,7 @@ import { titleize } from 'inflection';
4
4
  * Input: "payment.succeeded,payment.failed"
5
5
  * Output: ["payment.succeeded", "payment.failed"]
6
6
  */
7
- const parseEvents = (eventsInput) => {
7
+ export function parseEvents(eventsInput) {
8
8
  if (!eventsInput) {
9
9
  return [];
10
10
  }
@@ -12,13 +12,13 @@ const parseEvents = (eventsInput) => {
12
12
  .split(',')
13
13
  .map((e) => e.trim())
14
14
  .filter(Boolean);
15
- };
15
+ }
16
16
  /**
17
17
  * Validate event format (model.action pattern)
18
18
  * Valid: "product.created", "payment.succeeded"
19
19
  * Invalid: "product", "created", "", ".created", "product."
20
20
  */
21
- const validateEventFormat = (events, onError) => {
21
+ export function validateEventFormat(events, onError) {
22
22
  const invalid = [];
23
23
  for (const event of events) {
24
24
  const parts = event.split('.');
@@ -29,24 +29,29 @@ const validateEventFormat = (events, onError) => {
29
29
  if (invalid.length > 0) {
30
30
  onError(`Invalid event format: ${invalid.join(', ')}\n\nEvents must follow the 'model.action' pattern (e.g., product.created, payment.succeeded).\n\nExample: swell create webhook my-hook -u https://example.com -e order.created,order.updated -y`, { exit: 1 });
31
31
  }
32
- };
32
+ }
33
33
  /**
34
34
  * Validate URL format (basic check for protocol)
35
35
  */
36
- const validateUrl = (url, onError) => {
36
+ export function validateUrl(url, onError) {
37
37
  try {
38
38
  const parsed = new URL(url);
39
- if (!['http:', 'https:'].includes(parsed.protocol)) {
40
- throw new Error('Invalid protocol');
39
+ switch (parsed.protocol) {
40
+ case 'http:':
41
+ case 'https:': {
42
+ break;
43
+ }
44
+ default: {
45
+ throw new Error('Invalid protocol');
46
+ }
41
47
  }
42
48
  }
43
49
  catch {
44
50
  onError(`Invalid URL format: ${url}\n\nURL must be a valid HTTP or HTTPS endpoint.\n\nExample: swell create webhook my-hook -u https://example.com/webhook -e order.created -y`, { exit: 1 });
45
51
  }
46
- };
52
+ }
47
53
  /**
48
54
  * Convert name to webhook label
49
55
  * "payment-handler" => "Payment Handler"
50
56
  */
51
- const toWebhookLabel = (value) => titleize(value).replaceAll('-', ' ');
52
- export { parseEvents, toWebhookLabel, validateEventFormat, validateUrl, };
57
+ export const toWebhookLabel = (value) => titleize(value).replaceAll('-', ' ');
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs';
1
+ import * as fs from 'node:fs/promises';
2
2
  import { createRequire } from 'node:module';
3
3
  const require = createRequire(import.meta.url);
4
4
  const ts = require('typescript');
@@ -11,7 +11,7 @@ const WORKFLOW_FORBIDDEN_KEYS = [
11
11
  'timeout',
12
12
  ];
13
13
  export async function analyzeFunctionSource(filePath) {
14
- const sourceText = await fs.promises.readFile(filePath, 'utf8');
14
+ const sourceText = await fs.readFile(filePath, 'utf8');
15
15
  return analyzeFunctionSourceText(sourceText, filePath);
16
16
  }
17
17
  export function analyzeFunctionSourceText(sourceText, filePath = 'function.ts') {
@@ -207,7 +207,7 @@ function validateWorkflowConfig(config) {
207
207
  }
208
208
  const diagnostics = [];
209
209
  for (const key of WORKFLOW_FORBIDDEN_KEYS) {
210
- if (key in config) {
210
+ if (Object.hasOwn(config, key)) {
211
211
  diagnostics.push(`Workflow config must not specify ${key}.`);
212
212
  }
213
213
  }
@@ -2,7 +2,7 @@
2
2
  * Helper module for the `info` command. Encapsulates the logic for
3
3
  * displaying the app's information.
4
4
  */
5
- import { App, AppVersion } from './apps';
5
+ import type { App, AppVersion } from './apps/index.js';
6
6
  interface FieldDefinition {
7
7
  label: string;
8
8
  transform?: (_arg: any) => Promise<string> | string;
@@ -1,3 +1,4 @@
1
+ import type { LogItem } from '../../types/index.js';
1
2
  export { LineOutput } from './line-output.js';
2
3
  export { TableOutput } from './table-output.js';
3
4
  /**
@@ -1,3 +1,4 @@
1
+ import type { LogItem } from '../../types/index.js';
1
2
  import { Output } from './output.js';
2
3
  export declare class LineOutput extends Output {
3
4
  prepareData(log: LogItem): string[];
@@ -1,10 +1,18 @@
1
1
  import { Output } from './output.js';
2
- const COLUMN_NAMES_TO_HIDE = new Set(['date', 'request']);
3
2
  export class LineOutput extends Output {
4
3
  prepareData(log) {
5
- return this.columns.map((c) => {
6
- const logValue = log[c];
7
- return COLUMN_NAMES_TO_HIDE.has(c) ? logValue : `${c}: ${logValue}`;
4
+ return this.columns.map((column) => {
5
+ const logValue = log[column];
6
+ switch (column) {
7
+ case 'date':
8
+ case 'request': {
9
+ // Hide column name
10
+ return logValue;
11
+ }
12
+ default: {
13
+ return `${column}: ${logValue}`;
14
+ }
15
+ }
8
16
  });
9
17
  }
10
18
  write(row) {
@@ -1,3 +1,4 @@
1
+ import type { LogItem } from '../../types/index.js';
1
2
  export declare abstract class Output {
2
3
  protected columns: string[];
3
4
  protected pretty: boolean;
@@ -1,3 +1,4 @@
1
+ import type { LogItem } from '../../types/index.js';
1
2
  import { Output } from './output.js';
2
3
  export declare class TableOutput extends Output {
3
4
  private stream;
@@ -23,12 +23,12 @@ export class TableOutput extends Output {
23
23
  this.writeHeader();
24
24
  }
25
25
  prepareData(log) {
26
- return this.columns.map((c) => {
26
+ return this.columns.map((col) => {
27
27
  // for each column, get the value from the log item and prepare it for
28
28
  // display in the table, i.e. go through TableLoggedItem before returning
29
29
  const tableLog = new TableLoggedItem(log, this.pretty);
30
30
  const preparedLog = tableLog.prepareData();
31
- return preparedLog[c];
31
+ return preparedLog[col];
32
32
  });
33
33
  }
34
34
  write(row) {
@@ -94,7 +94,7 @@ export class TableOutput extends Output {
94
94
  return { width, wrapWord };
95
95
  }
96
96
  writeHeader() {
97
- this.stream.write(this.columns.map((c) => this.displayOptions(c)?.title || titleize(c)));
97
+ this.stream.write(this.columns.map((col) => this.displayOptions(col)?.title || titleize(col)));
98
98
  }
99
99
  }
100
100
  /**
@@ -120,8 +120,11 @@ class TableLoggedItem {
120
120
  logData = JSON.stringify(logData, null, 2);
121
121
  }
122
122
  }
123
- catch {
124
- // do nothing, JSON parsing errors
123
+ catch (error) {
124
+ // Ignore JSON parsing errors
125
+ if (!(error instanceof SyntaxError)) {
126
+ throw error;
127
+ }
125
128
  }
126
129
  return logData;
127
130
  }
@@ -15,16 +15,16 @@ export interface PackageManagerCommands {
15
15
  * Find lock file in directory or parent directories
16
16
  * @returns Lock file name and path, or null if not found
17
17
  */
18
- export declare function findLockFile(directory: string): {
18
+ export declare function findLockFile(directory: string): Promise<{
19
19
  name: string;
20
20
  packageManager: PackageManager;
21
21
  path: string;
22
- } | null;
22
+ } | null>;
23
23
  /**
24
24
  * Detect package manager from lock file in directory tree
25
25
  * @returns Detected package manager, defaults to 'npm' if no lock file found
26
26
  */
27
- export declare function detectPackageManager(directory: string): PackageManager;
27
+ export declare function detectPackageManager(directory: string): Promise<PackageManager>;
28
28
  /**
29
29
  * Get command templates for a package manager
30
30
  */
@@ -32,14 +32,14 @@ export declare function getPackageManagerCommands(pm: PackageManager): PackageMa
32
32
  /**
33
33
  * Detect package manager and get its commands
34
34
  */
35
- export declare function getPackageManager(directory: string): {
35
+ export declare function getPackageManager(directory: string): Promise<{
36
36
  commands: PackageManagerCommands;
37
37
  lockFile: {
38
38
  name: string;
39
39
  path: string;
40
40
  } | null;
41
41
  name: PackageManager;
42
- };
42
+ }>;
43
43
  /**
44
44
  * Transform an npm command to the equivalent for the detected package manager
45
45
  * Handles common patterns:
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs';
1
+ import * as fs from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
3
  /** Lock file to package manager mapping (priority order: bun > pnpm > yarn > npm) */
4
4
  const LOCK_FILES = [
@@ -44,13 +44,15 @@ const COMMANDS = {
44
44
  * Find lock file in directory or parent directories
45
45
  * @returns Lock file name and path, or null if not found
46
46
  */
47
- export function findLockFile(directory) {
47
+ export async function findLockFile(directory) {
48
48
  let currentDir = path.resolve(directory);
49
49
  const { root } = path.parse(currentDir);
50
50
  while (currentDir !== root) {
51
51
  for (const [lockFile, pm] of LOCK_FILES) {
52
52
  const lockPath = path.join(currentDir, lockFile);
53
- if (fs.existsSync(lockPath)) {
53
+ // eslint-disable-next-line no-await-in-loop
54
+ const exists = await fs.access(lockPath, fs.constants.R_OK).then(() => true, (_error) => false);
55
+ if (exists) {
54
56
  return { name: lockFile, packageManager: pm, path: lockPath };
55
57
  }
56
58
  }
@@ -62,8 +64,8 @@ export function findLockFile(directory) {
62
64
  * Detect package manager from lock file in directory tree
63
65
  * @returns Detected package manager, defaults to 'npm' if no lock file found
64
66
  */
65
- export function detectPackageManager(directory) {
66
- const lockFile = findLockFile(directory);
67
+ export async function detectPackageManager(directory) {
68
+ const lockFile = await findLockFile(directory);
67
69
  return lockFile?.packageManager ?? 'npm';
68
70
  }
69
71
  /**
@@ -75,8 +77,8 @@ export function getPackageManagerCommands(pm) {
75
77
  /**
76
78
  * Detect package manager and get its commands
77
79
  */
78
- export function getPackageManager(directory) {
79
- const lockFile = findLockFile(directory);
80
+ export async function getPackageManager(directory) {
81
+ const lockFile = await findLockFile(directory);
80
82
  const name = lockFile?.packageManager ?? 'npm';
81
83
  return {
82
84
  commands: COMMANDS[name],
package/dist/lib/proxy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { bin, install, Tunnel } from 'cloudflared';
2
2
  import localtunnel from 'localtunnel';
3
- import * as fs from 'node:fs';
3
+ import * as fs from 'node:fs/promises';
4
4
  import ora from 'ora';
5
5
  import { LOCAL_PROXY_PROVIDER } from './constants.js';
6
6
  let activeTunnel = null;
@@ -12,7 +12,8 @@ async function startCloudflaredTunnel(port) {
12
12
  activeTunnel = null;
13
13
  }
14
14
  // Ensure cloudflared binary is installed
15
- if (!fs.existsSync(bin)) {
15
+ const exists = await fs.access(bin, fs.constants.X_OK).then(() => true, (_error) => false);
16
+ if (!exists) {
16
17
  const spinner = ora('Installing cloudflared tunnel (first time only)...').start();
17
18
  await install(bin);
18
19
  spinner.stop();
@@ -82,6 +83,6 @@ export async function getProxyUrl(port, context) {
82
83
  }
83
84
  catch (error) {
84
85
  console.error(error);
85
- throw new Error(`Unable to start tunnel on port ${port} (${provider}): ${error.message}`);
86
+ throw new Error(`Unable to start tunnel on port ${port} (${provider}): ${error.message}`, { cause: error });
86
87
  }
87
88
  }
@@ -5,5 +5,4 @@
5
5
  * @param storeId - The store to get the session id for
6
6
  * @returns A promise that resolves to the session id
7
7
  */
8
- declare function getSessionIdOrLoginInBrowser(storeId?: string | undefined): Promise<string[]>;
9
- export { getSessionIdOrLoginInBrowser };
8
+ export declare function getSessionIdOrLoginInBrowser(storeId?: string | undefined): Promise<string[]>;
@@ -11,7 +11,7 @@ import style from './style.js';
11
11
  * @param storeId - The store to get the session id for
12
12
  * @returns A promise that resolves to the session id
13
13
  */
14
- function getSessionIdOrLoginInBrowser(storeId) {
14
+ export function getSessionIdOrLoginInBrowser(storeId) {
15
15
  return new Promise((resolve, _reject) => {
16
16
  const onSessionId = (sessionId, storeId) => resolve([sessionId, storeId]);
17
17
  createServer(onSessionId, storeId);
@@ -108,4 +108,3 @@ function serverForLogin({ onPost, onStart, storeId, }) {
108
108
  }
109
109
  }, 100);
110
110
  }
111
- export { getSessionIdOrLoginInBrowser };
@@ -1,3 +1,4 @@
1
+ import type { Store, UserAuthorization } from '../types/index.js';
1
2
  /**
2
3
  * Builds a list of stores while also highlighting the current store.
3
4
  *
@@ -12,7 +13,7 @@
12
13
  * @param currentStoreId - The ID of the default store
13
14
  * @returns A list of stores ready to display.
14
15
  */
15
- declare function showStores(stores: Store[], currentStoreId: string): string;
16
+ export declare function showStores(stores: Store[], currentStoreId: string): string;
16
17
  /**
17
18
  * Select the store to login to from a CLI prompt.
18
19
  *
@@ -26,7 +27,7 @@ declare function showStores(stores: Store[], currentStoreId: string): string;
26
27
  *
27
28
  * @returns The store ID to login to
28
29
  */
29
- declare function selectStoreId({ authorizations, currentStoreId, force, }: {
30
+ export declare function selectStoreId({ authorizations, currentStoreId, force, }: {
30
31
  authorizations: UserAuthorization[];
31
32
  currentStoreId: string;
32
33
  force: boolean;
@@ -39,7 +40,7 @@ declare function selectStoreId({ authorizations, currentStoreId, force, }: {
39
40
  * @returns The store ID to switch to
40
41
  * @throws CLIError - If there are no stores to switch to
41
42
  */
42
- declare function selectLoggedInStoreId(message?: string): Promise<string>;
43
+ export declare function selectLoggedInStoreId(message?: string): Promise<string>;
43
44
  /**
44
45
  * Select an environment.
45
46
  *
@@ -47,7 +48,7 @@ declare function selectLoggedInStoreId(message?: string): Promise<string>;
47
48
  * @returns Environment to switch to
48
49
  * @throws CLIError - If there are no stores to switch to
49
50
  */
50
- declare function selectEnvironmentId(message?: string): Promise<string>;
51
+ export declare function selectEnvironmentId(message?: string): Promise<string>;
51
52
  /**
52
53
  * Ask the user if they want to make the given store id the default store.
53
54
  *
@@ -61,8 +62,7 @@ declare function selectEnvironmentId(message?: string): Promise<string>;
61
62
  *
62
63
  * @returns void
63
64
  */
64
- declare function modifyDefaultStore({ currentStoreId, storeId, }: {
65
+ export declare function modifyDefaultStore({ currentStoreId, storeId, }: {
65
66
  currentStoreId: string;
66
67
  storeId: string;
67
68
  }, force?: boolean): Promise<void>;
68
- export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };
@@ -16,7 +16,7 @@ import style from './style.js';
16
16
  * @param currentStoreId - The ID of the default store
17
17
  * @returns A list of stores ready to display.
18
18
  */
19
- function showStores(stores, currentStoreId) {
19
+ export function showStores(stores, currentStoreId) {
20
20
  if (stores.length === 0) {
21
21
  throw new CLIError('You are not logged in to any store.');
22
22
  }
@@ -55,7 +55,7 @@ function showStores(stores, currentStoreId) {
55
55
  *
56
56
  * @returns The store ID to login to
57
57
  */
58
- async function selectStoreId({ authorizations, currentStoreId, force = false, }) {
58
+ export async function selectStoreId({ authorizations, currentStoreId, force = false, }) {
59
59
  let selectStoreChoices;
60
60
  let selectedStoreId;
61
61
  // eslint-disable-next-line unicorn/prefer-ternary
@@ -105,7 +105,7 @@ async function selectStoreId({ authorizations, currentStoreId, force = false, })
105
105
  * @returns The store ID to switch to
106
106
  * @throws CLIError - If there are no stores to switch to
107
107
  */
108
- async function selectLoggedInStoreId(message) {
108
+ export async function selectLoggedInStoreId(message) {
109
109
  const currentStoreId = config.getDefaultStore();
110
110
  const loggedInStores = config.get('stores') || [];
111
111
  if (loggedInStores.length === 0) {
@@ -136,7 +136,7 @@ async function selectLoggedInStoreId(message) {
136
136
  * @returns Environment to switch to
137
137
  * @throws CLIError - If there are no stores to switch to
138
138
  */
139
- async function selectEnvironmentId(message) {
139
+ export async function selectEnvironmentId(message) {
140
140
  return select({
141
141
  choices: [
142
142
  {
@@ -164,7 +164,7 @@ async function selectEnvironmentId(message) {
164
164
  *
165
165
  * @returns void
166
166
  */
167
- async function modifyDefaultStore({ currentStoreId, storeId, }, force = false) {
167
+ export async function modifyDefaultStore({ currentStoreId, storeId, }, force = false) {
168
168
  let modifyDefault = false;
169
169
  if (!force && currentStoreId && currentStoreId !== storeId) {
170
170
  modifyDefault = await confirm({
@@ -175,4 +175,3 @@ async function modifyDefaultStore({ currentStoreId, storeId, }, force = false) {
175
175
  config.setDefaultStore(storeId);
176
176
  }
177
177
  }
178
- export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };