@swell/cli 2.9.3 → 2.9.5
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/dist/app-command.d.ts +2 -3
- package/dist/app-command.js +3 -6
- package/dist/commands/app/dev.d.ts +2 -2
- package/dist/commands/app/dev.js +49 -33
- package/dist/commands/app/frontend/dev.js +12 -6
- package/dist/commands/app/push.d.ts +1 -0
- package/dist/commands/app/push.js +3 -3
- package/dist/commands/app/release.js +2 -2
- package/dist/commands/create/app.d.ts +1 -1
- package/dist/commands/create/app.js +1 -1
- package/dist/commands/create/frontend.js +3 -3
- package/dist/commands/create/tests.js +10 -8
- package/dist/commands/inspect/extensions.js +4 -4
- package/dist/commands/schema.js +21 -18
- package/dist/commands/theme/dev.js +5 -5
- package/dist/commands/theme/push.d.ts +1 -0
- package/dist/commands/theme/push.js +3 -3
- package/dist/create-app-command.js +2 -2
- package/dist/create-config-command.d.ts +1 -1
- package/dist/create-config-command.js +3 -3
- package/dist/help/custom-help.d.ts +1 -1
- package/dist/help/types.d.ts +1 -1
- package/dist/lib/api.d.ts +1 -0
- package/dist/lib/api.js +1 -1
- package/dist/lib/app-config.d.ts +13 -8
- package/dist/lib/app-config.js +25 -23
- package/dist/lib/apps/app-config.d.ts +5 -5
- package/dist/lib/apps/app-config.js +53 -37
- package/dist/lib/apps/index.d.ts +15 -14
- package/dist/lib/apps/index.js +40 -23
- package/dist/lib/apps/paths.d.ts +1 -1
- package/dist/lib/apps/paths.js +3 -3
- package/dist/lib/bundle.js +26 -17
- package/dist/lib/config.d.ts +8 -8
- package/dist/lib/config.js +8 -10
- package/dist/lib/constants.d.ts +9 -9
- package/dist/lib/create/content.d.ts +6 -6
- package/dist/lib/create/content.js +7 -8
- package/dist/lib/create/function.d.ts +5 -6
- package/dist/lib/create/function.js +7 -8
- package/dist/lib/create/index.d.ts +8 -9
- package/dist/lib/create/index.js +7 -8
- package/dist/lib/create/model.d.ts +4 -4
- package/dist/lib/create/model.js +4 -5
- package/dist/lib/create/notification.d.ts +2 -3
- package/dist/lib/create/setting.d.ts +4 -4
- package/dist/lib/create/setting.js +3 -4
- package/dist/lib/create/tests/types.d.ts +3 -4
- package/dist/lib/create/tests.d.ts +1 -2
- package/dist/lib/create/tests.js +12 -13
- package/dist/lib/create/webhook.d.ts +6 -6
- package/dist/lib/create/webhook.js +15 -10
- package/dist/lib/function-source-analysis.js +3 -3
- package/dist/lib/info.d.ts +1 -1
- package/dist/lib/logs/index.d.ts +1 -0
- package/dist/lib/logs/line-output.d.ts +1 -0
- package/dist/lib/logs/line-output.js +12 -4
- package/dist/lib/logs/output.d.ts +1 -0
- package/dist/lib/logs/table-output.d.ts +1 -0
- package/dist/lib/logs/table-output.js +8 -5
- package/dist/lib/package-manager.d.ts +5 -5
- package/dist/lib/package-manager.js +9 -7
- package/dist/lib/proxy.js +4 -3
- package/dist/lib/sessions.d.ts +1 -2
- package/dist/lib/sessions.js +1 -2
- package/dist/lib/stores.d.ts +6 -6
- package/dist/lib/stores.js +5 -6
- package/dist/lib/swell-function-wrapper.d.ts +1 -193
- package/dist/lib/swell-function-wrapper.js +1 -1
- package/dist/lib/theme-sync.js +0 -5
- package/dist/push-app-command.d.ts +8 -6
- package/dist/push-app-command.js +45 -51
- package/dist/remote-app-command.d.ts +6 -4
- package/dist/remote-app-command.js +39 -25
- package/dist/swell-api-command.d.ts +1 -0
- package/dist/swell-api-command.js +3 -3
- package/dist/types/index.d.ts +94 -0
- package/dist/types/index.js +4 -0
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
export function validateUrl(url, onError) {
|
|
37
37
|
try {
|
|
38
38
|
const parsed = new URL(url);
|
|
39
|
-
|
|
40
|
-
|
|
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.
|
|
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
|
|
210
|
+
if (Object.hasOwn(config, key)) {
|
|
211
211
|
diagnostics.push(`Workflow config must not specify ${key}.`);
|
|
212
212
|
}
|
|
213
213
|
}
|
package/dist/lib/info.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/logs/index.d.ts
CHANGED
|
@@ -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((
|
|
6
|
-
const logValue = log[
|
|
7
|
-
|
|
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) {
|
|
@@ -23,12 +23,12 @@ export class TableOutput extends Output {
|
|
|
23
23
|
this.writeHeader();
|
|
24
24
|
}
|
|
25
25
|
prepareData(log) {
|
|
26
|
-
return this.columns.map((
|
|
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[
|
|
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((
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/lib/sessions.d.ts
CHANGED
|
@@ -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[]>;
|
package/dist/lib/sessions.js
CHANGED
|
@@ -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 };
|
package/dist/lib/stores.d.ts
CHANGED
|
@@ -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, };
|
package/dist/lib/stores.js
CHANGED
|
@@ -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, };
|
|
@@ -1,193 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Handle a function request.
|
|
3
|
-
* @param {Request} originalRequest from cloudflare
|
|
4
|
-
* @param {*} _env cloudflare environment vars
|
|
5
|
-
* @param {*} context cloudflare conttext
|
|
6
|
-
* @returns {Promise<SwellResponse>}
|
|
7
|
-
*/
|
|
8
|
-
declare function request(originalRequest: Request, _env: any, context: any): Promise<SwellResponse>;
|
|
9
|
-
/**
|
|
10
|
-
* Invokes one of the function types that are available.
|
|
11
|
-
*
|
|
12
|
-
* Type-1: Named export function handlers
|
|
13
|
-
* ```
|
|
14
|
-
* export function post (req) {
|
|
15
|
-
*
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Important note:
|
|
20
|
-
* - `delete` func cannot be implemented in Type-1 since it's a reserved name. So, consider using Type-3.
|
|
21
|
-
*
|
|
22
|
-
* Type-2: Default export function handlers
|
|
23
|
-
* ```
|
|
24
|
-
* export default function (req) {
|
|
25
|
-
*
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* Type-3: Default object with named function handlers
|
|
30
|
-
* ```
|
|
31
|
-
* export default {
|
|
32
|
-
* delete(req) {
|
|
33
|
-
*
|
|
34
|
-
* },
|
|
35
|
-
* post(req) {
|
|
36
|
-
*
|
|
37
|
-
* },
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @param {SwellRequest} req
|
|
42
|
-
* @param {Event} context
|
|
43
|
-
*/
|
|
44
|
-
declare function executeModuleHandler(req: SwellRequest, context: Event): Promise<any>;
|
|
45
|
-
/**
|
|
46
|
-
* Helper to determine if a value is an ordinary object.
|
|
47
|
-
* @param {any} obj
|
|
48
|
-
* @returns {boolean}
|
|
49
|
-
*/
|
|
50
|
-
declare function isOrdinaryObject(val: any): boolean;
|
|
51
|
-
declare function validateWorkflowParams(params: any): any;
|
|
52
|
-
declare function validateWorkflowParamValue(value: any, seen?: WeakSet<object>): void;
|
|
53
|
-
declare function validateWorkflowParamArray(value: any, seen: any): void;
|
|
54
|
-
declare function validateWorkflowParamObject(value: any, seen: any): void;
|
|
55
|
-
declare function createWorkflowParamsError(code: any, message: any): SwellError;
|
|
56
|
-
declare namespace originalConsole {
|
|
57
|
-
let log: {
|
|
58
|
-
(...data: any[]): void;
|
|
59
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
60
|
-
};
|
|
61
|
-
let info: {
|
|
62
|
-
(...data: any[]): void;
|
|
63
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
64
|
-
};
|
|
65
|
-
let debug: {
|
|
66
|
-
(...data: any[]): void;
|
|
67
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
68
|
-
};
|
|
69
|
-
let warn: {
|
|
70
|
-
(...data: any[]): void;
|
|
71
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
72
|
-
};
|
|
73
|
-
let error: {
|
|
74
|
-
(...data: any[]): void;
|
|
75
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
declare const WORKFLOW_PARAMS_MAX_BYTES: number;
|
|
79
|
-
/**
|
|
80
|
-
* Class representing a Swell request.
|
|
81
|
-
*/
|
|
82
|
-
declare class SwellRequest {
|
|
83
|
-
constructor(req: any, context: any);
|
|
84
|
-
originalRequest: any;
|
|
85
|
-
context: any;
|
|
86
|
-
appId: any;
|
|
87
|
-
storeId: any;
|
|
88
|
-
accessToken: any;
|
|
89
|
-
publicKey: any;
|
|
90
|
-
store: any;
|
|
91
|
-
session: any;
|
|
92
|
-
logParams: any;
|
|
93
|
-
apiHost: any;
|
|
94
|
-
id: any;
|
|
95
|
-
isLocalDev: boolean;
|
|
96
|
-
swell: SwellAPI;
|
|
97
|
-
rawBody: string;
|
|
98
|
-
body: {};
|
|
99
|
-
query: {};
|
|
100
|
-
data: {};
|
|
101
|
-
_logs: any[];
|
|
102
|
-
assignRequestProps(req: any): void;
|
|
103
|
-
initialize(): Promise<void>;
|
|
104
|
-
url: URL | undefined;
|
|
105
|
-
parseJson(input: any): any;
|
|
106
|
-
log(level: any, ...line: any[]): void;
|
|
107
|
-
getIngestableLogs(response: any): {
|
|
108
|
-
params: any;
|
|
109
|
-
} | undefined;
|
|
110
|
-
formatRequestData(): string;
|
|
111
|
-
ingestLogs(response: any): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Merge values into app data for the current request.
|
|
114
|
-
* @param {object|string} idOrValues string to indicate app ID, or values to merge
|
|
115
|
-
* @param {object|undefined} values values to merge into app data
|
|
116
|
-
* @returns {object} existing app data merged with values
|
|
117
|
-
* @throws {Error} if app id is missing or values is not a plain object
|
|
118
|
-
*/
|
|
119
|
-
appValues(idOrValues: object | string, values: object | undefined): object;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Class representing the Swell backend API.
|
|
123
|
-
*/
|
|
124
|
-
declare class SwellAPI {
|
|
125
|
-
constructor(req: any, context: any);
|
|
126
|
-
request: any;
|
|
127
|
-
baseUrl: any;
|
|
128
|
-
basicAuth: string;
|
|
129
|
-
context: any;
|
|
130
|
-
workflows: {
|
|
131
|
-
create: (name: any, params: any) => Promise<any>;
|
|
132
|
-
};
|
|
133
|
-
toBase64(inputString: any): string;
|
|
134
|
-
stringifyQuery(queryObject: any, prefix: any): any;
|
|
135
|
-
makeRequest(method: any, url: any, data: any): Promise<any>;
|
|
136
|
-
get(url: any, query: any): Promise<any>;
|
|
137
|
-
put(url: any, data: any): Promise<any>;
|
|
138
|
-
post(url: any, data: any): Promise<any>;
|
|
139
|
-
delete(url: any, data: any): Promise<any>;
|
|
140
|
-
settings(id?: any): Promise<any>;
|
|
141
|
-
createWorkflow(name: any, params: any): Promise<any>;
|
|
142
|
-
/**
|
|
143
|
-
* Atomic multi-op write. Throws SwellError with a stable `error.code`
|
|
144
|
-
* (transaction_conflict | transaction_timeout | transaction_throttled
|
|
145
|
-
* | transaction_op_failed | transaction_error). Retry is off by
|
|
146
|
-
* default — opt in with `{ retry: true }` or pass overrides.
|
|
147
|
-
*
|
|
148
|
-
* @param {Array<{method: string, url: string, data?: any}>} ops
|
|
149
|
-
* @param {{ retry?: true | { limit?: number, base?: number, max?: number, jitter?: boolean } }} [opts]
|
|
150
|
-
* @returns {Promise<any[]>}
|
|
151
|
-
*/
|
|
152
|
-
transaction(ops: Array<{
|
|
153
|
-
method: string;
|
|
154
|
-
url: string;
|
|
155
|
-
data?: any;
|
|
156
|
-
}>, opts?: {
|
|
157
|
-
retry?: true | {
|
|
158
|
-
limit?: number | undefined;
|
|
159
|
-
base?: number | undefined;
|
|
160
|
-
max?: number | undefined;
|
|
161
|
-
jitter?: boolean | undefined;
|
|
162
|
-
} | undefined;
|
|
163
|
-
} | undefined): Promise<any[]>;
|
|
164
|
-
}
|
|
165
|
-
declare const DEFAULT_RETRY: Readonly<{
|
|
166
|
-
limit: 3;
|
|
167
|
-
base: 100;
|
|
168
|
-
max: 5000;
|
|
169
|
-
jitter: true;
|
|
170
|
-
}>;
|
|
171
|
-
declare const RETRYABLE_CODES: Set<string>;
|
|
172
|
-
/**
|
|
173
|
-
* Class representing a Swell error.
|
|
174
|
-
*/
|
|
175
|
-
declare class SwellError extends Error {
|
|
176
|
-
constructor(message: any, options?: {});
|
|
177
|
-
status: any;
|
|
178
|
-
body: any;
|
|
179
|
-
code: any;
|
|
180
|
-
retry: any;
|
|
181
|
-
get isRetryable(): boolean;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Class representing a Swell response.
|
|
185
|
-
*/
|
|
186
|
-
declare class SwellResponse extends Response {
|
|
187
|
-
static _respond(req: any, response: any, context: any): Promise<any>;
|
|
188
|
-
static _consumeNativeResponse(response: any): Promise<SwellResponse>;
|
|
189
|
-
static _respondWithLogs(response: any, req: any): SwellResponse;
|
|
190
|
-
constructor(data: any, options?: {});
|
|
191
|
-
_swellData: any;
|
|
192
|
-
_swellOptions: {};
|
|
193
|
-
}
|
|
1
|
+
export {};
|
package/dist/lib/theme-sync.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import getPort, { portNumbers } from 'get-port';
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
-
// @ts-ignore - http-proxy has incomplete TypeScript definitions
|
|
4
2
|
import httpProxy from 'http-proxy';
|
|
5
3
|
import http from 'node:http';
|
|
6
4
|
import util from 'node:util';
|
|
7
5
|
import zlib from 'node:zlib';
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
-
// @ts-ignore - ws library uses named exports differently
|
|
10
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
11
6
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
12
7
|
const gunzipAsync = util.promisify(zlib.gunzip);
|
|
13
8
|
const inflateAsync = util.promisify(zlib.inflate);
|