@swell/cli 2.0.11 → 2.0.13
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/commands/app/dev.d.ts +2 -2
- package/dist/commands/app/dev.js +2 -2
- package/dist/commands/app/install.js +1 -1
- package/dist/commands/app/pull.d.ts +4 -1
- package/dist/commands/app/pull.js +9 -6
- package/dist/commands/app/push.d.ts +4 -2
- package/dist/commands/app/push.js +2 -2
- package/dist/commands/app/release.d.ts +3 -0
- package/dist/commands/app/release.js +3 -0
- package/dist/commands/app/version.d.ts +3 -0
- package/dist/commands/app/version.js +3 -0
- package/dist/commands/create/app.d.ts +1 -1
- package/dist/commands/create/app.js +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/theme/dev.d.ts +2 -4
- package/dist/commands/theme/dev.js +13 -7
- package/dist/commands/theme/init.d.ts +1 -1
- package/dist/commands/theme/init.js +1 -1
- package/dist/commands/theme/pull.d.ts +3 -3
- package/dist/commands/theme/pull.js +6 -3
- package/dist/commands/theme/push.d.ts +2 -3
- package/dist/commands/theme/push.js +18 -5
- package/dist/lib/api.d.ts +5 -4
- package/dist/lib/api.js +16 -3
- package/dist/lib/apps/app-config.d.ts +6 -6
- package/dist/lib/apps/app-config.js +4 -5
- package/dist/lib/apps/index.d.ts +36 -35
- package/dist/lib/apps/index.js +60 -62
- package/dist/lib/apps/paths.d.ts +10 -9
- package/dist/lib/apps/paths.js +36 -32
- package/dist/lib/config.d.ts +5 -2
- package/dist/lib/config.js +11 -3
- package/dist/lib/stores.js +2 -2
- package/dist/push-app-command.d.ts +24 -9
- package/dist/push-app-command.js +114 -63
- package/dist/remote-app-command.d.ts +2 -2
- package/dist/remote-app-command.js +14 -8
- package/oclif.manifest.json +41 -7
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PushAppCommand } from '../../push-app-command.js';
|
|
2
2
|
export default class AppDev extends PushAppCommand {
|
|
3
|
-
static delayOrientation: boolean;
|
|
4
3
|
static examples: string[];
|
|
5
4
|
static flags: {
|
|
6
5
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
@@ -8,9 +7,10 @@ export default class AppDev extends PushAppCommand {
|
|
|
8
7
|
'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
8
|
port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
9
|
};
|
|
10
|
+
static summary: string;
|
|
11
|
+
static delayOrientation: boolean;
|
|
11
12
|
static orientation: {
|
|
12
13
|
env: string;
|
|
13
14
|
};
|
|
14
|
-
static summary: string;
|
|
15
15
|
run(): Promise<void>;
|
|
16
16
|
}
|
package/dist/commands/app/dev.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Flags } from '@oclif/core';
|
|
|
2
2
|
import { PushAppCommand } from '../../push-app-command.js';
|
|
3
3
|
import AppFrontendDev from './frontend/dev.js';
|
|
4
4
|
export default class AppDev extends PushAppCommand {
|
|
5
|
-
static delayOrientation = true;
|
|
6
5
|
static examples = [
|
|
7
6
|
'swell app dev',
|
|
8
7
|
'swell app dev --storefront-id <id>',
|
|
@@ -18,10 +17,11 @@ export default class AppDev extends PushAppCommand {
|
|
|
18
17
|
description: 'for storefront apps, prompt to select a storefront to preview',
|
|
19
18
|
}),
|
|
20
19
|
};
|
|
20
|
+
static summary = `Run an app in dev mode from your local machine.`;
|
|
21
|
+
static delayOrientation = true;
|
|
21
22
|
static orientation = {
|
|
22
23
|
env: 'test',
|
|
23
24
|
};
|
|
24
|
-
static summary = `Run an app in dev mode from your local machine.`;
|
|
25
25
|
async run() {
|
|
26
26
|
await this.config.runCommand('app:frontend:dev', this.argv);
|
|
27
27
|
}
|
|
@@ -76,7 +76,7 @@ Without a store specified, install the app in the Live environment of the curren
|
|
|
76
76
|
this.error(`You cannot install an app in the test environment of the same store.`);
|
|
77
77
|
}
|
|
78
78
|
config.ensureLoggedIn(storeToInstall);
|
|
79
|
-
this.api.setStoreEnv(storeToInstall, envToInstall);
|
|
79
|
+
await this.api.setStoreEnv(storeToInstall, envToInstall);
|
|
80
80
|
// check if app is already installed on store
|
|
81
81
|
const existingInstalledApp = await this.getInstalledApp();
|
|
82
82
|
const existingVersion = existingInstalledApp?.id
|
|
@@ -9,7 +9,10 @@ export default class AppPull extends PushAppCommand {
|
|
|
9
9
|
static flags: {
|
|
10
10
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
|
+
static orientation: {
|
|
13
|
+
env: string;
|
|
14
|
+
};
|
|
12
15
|
static summary: string;
|
|
13
|
-
logPulledChanges(pulled: string[], removed: string[]): void;
|
|
14
16
|
run(): Promise<void>;
|
|
17
|
+
logPulledChanges(pulled: string[], removed: string[]): void;
|
|
15
18
|
}
|
|
@@ -32,13 +32,10 @@ ${Object.values(ConfigPaths)
|
|
|
32
32
|
description: 'force pull all files',
|
|
33
33
|
}),
|
|
34
34
|
};
|
|
35
|
+
static orientation = {
|
|
36
|
+
env: 'test',
|
|
37
|
+
};
|
|
35
38
|
static summary = 'Pull app files from Swell to your local machine.';
|
|
36
|
-
logPulledChanges(pulled, removed) {
|
|
37
|
-
const typeLabel = this.appType === 'theme' ? 'theme' : 'app';
|
|
38
|
-
const changeCount = pulled.length + removed.length;
|
|
39
|
-
const pluralFiles = changeCount === 1 ? 'file' : 'files';
|
|
40
|
-
this.log(`Pulled ${changeCount} ${pluralFiles} from ${style.appConfigValue(this.app.name)} ${typeLabel} in ${style.path(path.resolve(this.appPath))}.`);
|
|
41
|
-
}
|
|
42
39
|
async run() {
|
|
43
40
|
const { args, flags } = await this.parse(AppPull);
|
|
44
41
|
const { force } = flags;
|
|
@@ -47,4 +44,10 @@ ${Object.values(ConfigPaths)
|
|
|
47
44
|
const { pulled, removed } = await this.pullAppConfigs(force);
|
|
48
45
|
this.logPulledChanges(pulled, removed);
|
|
49
46
|
}
|
|
47
|
+
logPulledChanges(pulled, removed) {
|
|
48
|
+
const typeLabel = this.appType === 'theme' ? 'theme' : 'app';
|
|
49
|
+
const changeCount = pulled.length + removed.length;
|
|
50
|
+
const pluralFiles = changeCount === 1 ? 'file' : 'files';
|
|
51
|
+
this.log(`Pulled ${changeCount} ${pluralFiles} from ${style.appConfigValue(this.app.name)} ${typeLabel} in ${style.path(path.resolve(this.appPath))}.`);
|
|
52
|
+
}
|
|
50
53
|
}
|
|
@@ -3,12 +3,14 @@ export default class AppPush extends PushAppCommand {
|
|
|
3
3
|
static args: {
|
|
4
4
|
file: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
|
-
static delayOrientation: boolean;
|
|
7
6
|
static description: string;
|
|
8
7
|
static examples: string[];
|
|
9
8
|
static flags: any;
|
|
10
|
-
static orientation: any;
|
|
11
9
|
static summary: string;
|
|
10
|
+
static delayOrientation: boolean;
|
|
11
|
+
static orientation: {
|
|
12
|
+
env: string;
|
|
13
|
+
};
|
|
12
14
|
resolvePushPaths(file: string): {
|
|
13
15
|
filePath: string;
|
|
14
16
|
relativePath: string;
|
|
@@ -10,7 +10,6 @@ export default class AppPush extends PushAppCommand {
|
|
|
10
10
|
description: 'relative path to a configuration file or directory to push',
|
|
11
11
|
}),
|
|
12
12
|
};
|
|
13
|
-
static delayOrientation = true;
|
|
14
13
|
static description = `Push all app files, a specific file, or a specific configuration
|
|
15
14
|
type to an app in your store's test environment.
|
|
16
15
|
|
|
@@ -39,10 +38,11 @@ ${Object.values(ConfigPaths)
|
|
|
39
38
|
description: 'skip deploying app frontend',
|
|
40
39
|
}),
|
|
41
40
|
};
|
|
41
|
+
static summary = 'Push local files to your Swell app.';
|
|
42
|
+
static delayOrientation = true;
|
|
42
43
|
static orientation = {
|
|
43
44
|
env: 'test',
|
|
44
45
|
};
|
|
45
|
-
static summary = 'Push local files to your Swell app.';
|
|
46
46
|
resolvePushPaths(file) {
|
|
47
47
|
// Join the appPath and file to get the absolute filePath
|
|
48
48
|
const filePath = path.resolve(process.cwd(), file);
|
|
@@ -7,6 +7,9 @@ export default class AppRelease extends PushAppCommand {
|
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: any;
|
|
9
9
|
static summary: string;
|
|
10
|
+
static orientation: {
|
|
11
|
+
env: string;
|
|
12
|
+
};
|
|
10
13
|
run(): Promise<void>;
|
|
11
14
|
validateReleaseDetails(): void;
|
|
12
15
|
private validateCreateVersion;
|
|
@@ -57,6 +57,9 @@ The app must be connected to a partner account with access to publish.`;
|
|
|
57
57
|
}),
|
|
58
58
|
};
|
|
59
59
|
static summary = 'Release a new version of your an app for publishing to the App Store.';
|
|
60
|
+
static orientation = {
|
|
61
|
+
env: 'test',
|
|
62
|
+
};
|
|
60
63
|
async run() {
|
|
61
64
|
const { args, flags } = await this.parse(AppRelease);
|
|
62
65
|
const { amend, message, 'not-supported': notSupported, 'release-notes': releaseNotesFile, yes, } = flags;
|
|
@@ -12,6 +12,9 @@ export default class AppVersion extends PushAppCommand {
|
|
|
12
12
|
yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
13
|
};
|
|
14
14
|
static summary: string;
|
|
15
|
+
static orientation: {
|
|
16
|
+
env: string;
|
|
17
|
+
};
|
|
15
18
|
run(): Promise<void>;
|
|
16
19
|
private createRemoteVersion;
|
|
17
20
|
private gitCommit;
|
|
@@ -68,6 +68,9 @@ behavior by using the --no-git-tag option.`;
|
|
|
68
68
|
}),
|
|
69
69
|
};
|
|
70
70
|
static summary = 'Increment the version of your Swell app.';
|
|
71
|
+
static orientation = {
|
|
72
|
+
env: 'test',
|
|
73
|
+
};
|
|
71
74
|
async run() {
|
|
72
75
|
const { args, flags } = await this.parse(AppVersion);
|
|
73
76
|
const { amend, 'no-git-tag': noGitTag, yes } = flags;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CreateAppCommand } from '../../create-app-command.js';
|
|
2
2
|
export default class CreateApp extends CreateAppCommand {
|
|
3
|
+
appType: string;
|
|
3
4
|
static args: {
|
|
4
5
|
id: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
6
|
};
|
|
@@ -9,7 +10,6 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
9
10
|
description: string;
|
|
10
11
|
}[];
|
|
11
12
|
static flags: any;
|
|
12
|
-
appType: string;
|
|
13
13
|
createSwellConfig({ allowOverwrite, inputId, inputStorefrontApp, inputType, inputYes, nestedPath, }: {
|
|
14
14
|
allowOverwrite?: boolean;
|
|
15
15
|
inputId: string;
|
|
@@ -7,6 +7,7 @@ import { newConfig, swellConfigFileExists } from '../../lib/app-config.js';
|
|
|
7
7
|
import { toAppId, toAppName } from '../../lib/create/index.js';
|
|
8
8
|
import style from '../../lib/style.js';
|
|
9
9
|
export default class CreateApp extends CreateAppCommand {
|
|
10
|
+
appType = '';
|
|
10
11
|
static args = {
|
|
11
12
|
id: Args.string({
|
|
12
13
|
default: '',
|
|
@@ -45,7 +46,6 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
45
46
|
options: ['admin', 'integration', 'storefront', 'theme'],
|
|
46
47
|
}),
|
|
47
48
|
};
|
|
48
|
-
appType = '';
|
|
49
49
|
async createSwellConfig({ allowOverwrite = true, inputId, inputStorefrontApp, inputType, inputYes, nestedPath = true, }) {
|
|
50
50
|
let confirmYes = inputYes;
|
|
51
51
|
const type = inputType ||
|
package/dist/commands/login.js
CHANGED
|
@@ -44,7 +44,7 @@ have available for logging in to.
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
const [sessionId, storeId] = await getSessionIdOrLoginInBrowser(store);
|
|
47
|
-
this.api.setStoreEnv(storeId);
|
|
47
|
+
await this.api.setStoreEnv(storeId);
|
|
48
48
|
user = await this.api.get({ adminPath: 'user' }, { sessionId });
|
|
49
49
|
await this.getAndSetStoreConfig({ sessionId, storeId });
|
|
50
50
|
await modifyDefaultStore({ currentStoreId, storeId }, force);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PushAppCommand } from '../../push-app-command.js';
|
|
2
2
|
export default class AppThemeDev extends PushAppCommand {
|
|
3
|
+
appType: string;
|
|
3
4
|
static examples: string[];
|
|
4
5
|
static flags: {
|
|
5
6
|
bundle: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
@@ -8,12 +9,9 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
8
9
|
'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
10
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
11
|
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
|
-
|
|
12
|
-
static orientation: {
|
|
13
|
-
env: string;
|
|
12
|
+
env: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
13
|
};
|
|
15
14
|
static summary: string;
|
|
16
|
-
appType: string;
|
|
17
15
|
logAppLocalUrl(storeId: string, sessionId: string): void;
|
|
18
16
|
run(): Promise<void>;
|
|
19
17
|
private findAndInstallDependencies;
|
|
@@ -10,6 +10,7 @@ import style from '../../lib/style.js';
|
|
|
10
10
|
import { PushAppCommand } from '../../push-app-command.js';
|
|
11
11
|
const FALLBACK_PORT = 3000;
|
|
12
12
|
export default class AppThemeDev extends PushAppCommand {
|
|
13
|
+
appType = 'theme';
|
|
13
14
|
static examples = [
|
|
14
15
|
'swell theme dev',
|
|
15
16
|
'swell theme dev --local',
|
|
@@ -38,12 +39,12 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
38
39
|
default: false,
|
|
39
40
|
description: 'prompt to select a storefront to preview and push theme files to',
|
|
40
41
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
env: Flags.string({
|
|
43
|
+
char: 'e',
|
|
44
|
+
description: 'target environment to push to, defaults to live',
|
|
45
|
+
}),
|
|
44
46
|
};
|
|
45
47
|
static summary = `Run a theme in dev mode from your local machine.`;
|
|
46
|
-
appType = 'theme';
|
|
47
48
|
logAppLocalUrl(storeId, sessionId) {
|
|
48
49
|
this.log(`View it at ${style.link(this.localFrontendUrl(storeId, sessionId))}\n`);
|
|
49
50
|
}
|
|
@@ -51,6 +52,10 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
51
52
|
const { flags } = await this.parse(AppThemeDev);
|
|
52
53
|
const { force, local } = flags;
|
|
53
54
|
const noPush = flags['no-push'];
|
|
55
|
+
await this.ensureLoggedIn();
|
|
56
|
+
// Set env from default storefront first
|
|
57
|
+
const defaultStorefront = localConfig.getDefaultStorefront(this.appPath);
|
|
58
|
+
await this.setStorefrontEnv(flags, defaultStorefront);
|
|
54
59
|
if (!(await this.ensureAppExists(undefined, false))) {
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
@@ -59,12 +64,13 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
59
64
|
const sessionId = localConfig.getSessionId(currentStore);
|
|
60
65
|
this.storefrontLocalUrl = this.localFrontendUrl(currentStore, sessionId);
|
|
61
66
|
}
|
|
62
|
-
if (!noPush) {
|
|
63
|
-
await this.pushAppConfigs(force);
|
|
64
|
-
}
|
|
65
67
|
await this.getStorefrontToPush(flags);
|
|
68
|
+
await this.logOrientation({ env: this.api.envId || 'live' });
|
|
66
69
|
this.logStorefrontConnected();
|
|
67
70
|
this.saveCurrentStorefront();
|
|
71
|
+
if (!noPush) {
|
|
72
|
+
await this.pushAppConfigs(force);
|
|
73
|
+
}
|
|
68
74
|
await this.startThemeDevServer(local);
|
|
69
75
|
}
|
|
70
76
|
async findAndInstallDependencies() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import InitApp from '../app/init.js';
|
|
2
2
|
export default class InitTheme extends InitApp {
|
|
3
|
+
appType = 'theme';
|
|
3
4
|
static description = 'Initialize theme swell.json in the current directory.';
|
|
4
5
|
static examples = [
|
|
5
6
|
{
|
|
@@ -11,5 +12,4 @@ export default class InitTheme extends InitApp {
|
|
|
11
12
|
description: 'Initialize theme and accept all default values.',
|
|
12
13
|
},
|
|
13
14
|
];
|
|
14
|
-
appType = 'theme';
|
|
15
15
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import AppPull from '../app/pull.js';
|
|
2
2
|
export default class AppThemePull extends AppPull {
|
|
3
|
+
appType: string;
|
|
3
4
|
static args: {
|
|
4
5
|
appId: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
6
|
targetPath: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
7
|
};
|
|
7
|
-
static delayOrientation: boolean;
|
|
8
8
|
static description: string;
|
|
9
9
|
static examples: string[];
|
|
10
10
|
static flags: {
|
|
11
11
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
12
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
13
|
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
+
env: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
15
|
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
16
|
};
|
|
16
|
-
static orientation: {};
|
|
17
17
|
static summary: string;
|
|
18
|
-
|
|
18
|
+
static delayOrientation: boolean;
|
|
19
19
|
run(): Promise<void>;
|
|
20
20
|
}
|
|
@@ -3,6 +3,7 @@ import { ThemeConfigPaths } from '../../lib/apps/index.js';
|
|
|
3
3
|
import style from '../../lib/style.js';
|
|
4
4
|
import AppPull from '../app/pull.js';
|
|
5
5
|
export default class AppThemePull extends AppPull {
|
|
6
|
+
appType = 'theme';
|
|
6
7
|
static args = {
|
|
7
8
|
appId: Args.string({
|
|
8
9
|
default: '',
|
|
@@ -13,7 +14,6 @@ export default class AppThemePull extends AppPull {
|
|
|
13
14
|
description: 'path to download theme files into',
|
|
14
15
|
}),
|
|
15
16
|
};
|
|
16
|
-
static delayOrientation = true;
|
|
17
17
|
static description = `Pull all theme files, a specific file, or a specific configuration
|
|
18
18
|
type from a theme in your store's test environment to your local machine.
|
|
19
19
|
|
|
@@ -43,14 +43,17 @@ ${Object.values(ThemeConfigPaths)
|
|
|
43
43
|
default: false,
|
|
44
44
|
description: 'prompt to select a storefront to pull theme files to',
|
|
45
45
|
}),
|
|
46
|
+
env: Flags.string({
|
|
47
|
+
char: 'e',
|
|
48
|
+
description: 'target environment to pull from, defaults to live',
|
|
49
|
+
}),
|
|
46
50
|
'sync-app': Flags.boolean({
|
|
47
51
|
default: false,
|
|
48
52
|
description: 'pull app files in addition to theme files to',
|
|
49
53
|
}),
|
|
50
54
|
};
|
|
51
|
-
static orientation = {};
|
|
52
55
|
static summary = 'Pull theme files from Swell to your local machine.';
|
|
53
|
-
|
|
56
|
+
static delayOrientation = true;
|
|
54
57
|
async run() {
|
|
55
58
|
const { args, flags } = await this.parse(AppThemePull);
|
|
56
59
|
const { force } = flags;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import AppPush from '../app/push.js';
|
|
2
2
|
export default class AppThemePush extends AppPush {
|
|
3
|
+
appType: string;
|
|
3
4
|
static args: {
|
|
4
5
|
file: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
5
6
|
};
|
|
6
|
-
static delayOrientation: boolean;
|
|
7
7
|
static description: string;
|
|
8
8
|
static examples: string[];
|
|
9
9
|
static flags: {
|
|
10
10
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
11
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
12
|
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
env: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
14
|
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
15
|
};
|
|
15
|
-
static orientation: {};
|
|
16
16
|
static summary: string;
|
|
17
|
-
appType: string;
|
|
18
17
|
run(): Promise<void>;
|
|
19
18
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { ThemeConfigPaths, filePathExists, isPathDirectory, } from '../../lib/apps/index.js';
|
|
3
|
+
import { default as localConfig } from '../../lib/config.js';
|
|
3
4
|
import style from '../../lib/style.js';
|
|
4
5
|
import AppPush from '../app/push.js';
|
|
5
6
|
export default class AppThemePush extends AppPush {
|
|
7
|
+
appType = 'theme';
|
|
6
8
|
static args = {
|
|
7
9
|
file: Args.string({
|
|
8
10
|
char: 'f',
|
|
9
11
|
description: 'relative path to a configuration file or directory to push',
|
|
10
12
|
}),
|
|
11
13
|
};
|
|
12
|
-
static delayOrientation = true;
|
|
13
14
|
static description = `Push all theme files, a specific file, or a specific configuration
|
|
14
15
|
type to an theme in your store's test environment.
|
|
15
16
|
|
|
@@ -45,19 +46,30 @@ ${Object.values(ThemeConfigPaths)
|
|
|
45
46
|
default: false,
|
|
46
47
|
description: 'prompt to select a storefront to push theme files to',
|
|
47
48
|
}),
|
|
49
|
+
env: Flags.string({
|
|
50
|
+
char: 'e',
|
|
51
|
+
description: 'target environment to push to, defaults to live',
|
|
52
|
+
}),
|
|
48
53
|
'sync-app': Flags.boolean({
|
|
49
54
|
default: false,
|
|
50
55
|
description: 'push app files in addition to theme files',
|
|
51
56
|
}),
|
|
52
57
|
};
|
|
53
|
-
static orientation = {};
|
|
54
58
|
static summary = 'Push local files to your Swell theme.';
|
|
55
|
-
appType = 'theme';
|
|
56
59
|
async run() {
|
|
57
60
|
const { args, flags } = await this.parse(AppThemePush);
|
|
58
61
|
const { file } = args;
|
|
59
62
|
const { force } = flags;
|
|
60
63
|
this.themeSyncApp = flags['sync-app'];
|
|
64
|
+
// Set default storefront env only if not syncing app, then it must be test env only
|
|
65
|
+
if (this.themeSyncApp) {
|
|
66
|
+
const currentStore = localConfig.getDefaultStore();
|
|
67
|
+
await this.api.setStoreEnv(currentStore, 'test');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const defaultStorefront = localConfig.getDefaultStorefront(this.appPath);
|
|
71
|
+
await this.setStorefrontEnv(flags, defaultStorefront);
|
|
72
|
+
}
|
|
61
73
|
if (!(await this.ensureAppExists(file, this.themeSyncApp))) {
|
|
62
74
|
return;
|
|
63
75
|
}
|
|
@@ -74,9 +86,10 @@ ${Object.values(ThemeConfigPaths)
|
|
|
74
86
|
this.error(`Path ${style.path(file)} does not exist.`);
|
|
75
87
|
}
|
|
76
88
|
// Targeting a directory
|
|
77
|
-
|
|
89
|
+
const pushPromise = isPathDirectory(filePath)
|
|
78
90
|
? this.pushFilePath(relativePath, force)
|
|
79
|
-
: this.pushFile(relativePath)
|
|
91
|
+
: this.pushFile(relativePath);
|
|
92
|
+
await pushPromise;
|
|
80
93
|
this.log();
|
|
81
94
|
this.logStorefrontFrontendUrl(this.storefront);
|
|
82
95
|
return;
|
package/dist/lib/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default class Api {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
envId: string | undefined;
|
|
3
|
+
secretKey: string | undefined;
|
|
4
|
+
storeId: string | undefined;
|
|
5
5
|
constructor(storeId?: string, envId?: string, secretKey?: string);
|
|
6
6
|
api(pathOpts: Api.Paths, options: Api.RequestOptions): Promise<any>;
|
|
7
7
|
delete(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
@@ -9,7 +9,8 @@ export default class Api {
|
|
|
9
9
|
isAdmin(): boolean;
|
|
10
10
|
post(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
11
11
|
put(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
12
|
-
setStoreEnv(storeId: string, envId?: string): void
|
|
12
|
+
setStoreEnv(storeId: string, envId?: string): Promise<void>;
|
|
13
|
+
isTestEnvEnabled(): Promise<boolean>;
|
|
13
14
|
truncatePath(path: string | undefined): string | undefined;
|
|
14
15
|
waitForAsyncResponse(response: any, pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
15
16
|
}
|
package/dist/lib/api.js
CHANGED
|
@@ -123,10 +123,22 @@ export default class Api {
|
|
|
123
123
|
});
|
|
124
124
|
return this.waitForAsyncResponse(response, pathOpts, options);
|
|
125
125
|
}
|
|
126
|
-
setStoreEnv(storeId, envId) {
|
|
126
|
+
async setStoreEnv(storeId, envId) {
|
|
127
|
+
if (envId) {
|
|
128
|
+
const hasTestEnv = await this.isTestEnvEnabled();
|
|
129
|
+
if (!hasTestEnv) {
|
|
130
|
+
throw new Error('Test environment is not enabled for this store.');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
127
133
|
this.storeId = storeId;
|
|
128
134
|
this.envId = envId;
|
|
129
135
|
}
|
|
136
|
+
async isTestEnvEnabled() {
|
|
137
|
+
const clientRecord = await this.get({
|
|
138
|
+
adminPath: `/client`,
|
|
139
|
+
});
|
|
140
|
+
return clientRecord.test_enabled !== false;
|
|
141
|
+
}
|
|
130
142
|
truncatePath(path) {
|
|
131
143
|
return path?.startsWith('/') ? path.slice(1) : path;
|
|
132
144
|
}
|
|
@@ -135,8 +147,9 @@ export default class Api {
|
|
|
135
147
|
if (!response?.async_progressing || !onAsyncGetPath) {
|
|
136
148
|
return response;
|
|
137
149
|
}
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
await new Promise((resolve) => {
|
|
151
|
+
setTimeout(resolve, 1000);
|
|
152
|
+
});
|
|
140
153
|
const asyncResponse = await this.api(onAsyncGetPath(response), {
|
|
141
154
|
method: 'GET',
|
|
142
155
|
onAsyncGetPath,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ConfigType } from './index.js';
|
|
3
|
-
declare class IgnoringFileError extends Error {
|
|
3
|
+
export declare class IgnoringFileError extends Error {
|
|
4
4
|
constructor(message: string);
|
|
5
5
|
}
|
|
6
|
-
declare class FunctionProcessingError extends Error {
|
|
6
|
+
export declare class FunctionProcessingError extends Error {
|
|
7
7
|
originalError: Error;
|
|
8
8
|
constructor(message: string, error: Error);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface AppConfigFile {
|
|
11
11
|
content_type?: string;
|
|
12
12
|
data?: string;
|
|
13
13
|
date_uploaded?: string;
|
|
@@ -16,12 +16,12 @@ type AppConfigFile = {
|
|
|
16
16
|
length?: number;
|
|
17
17
|
md5?: string;
|
|
18
18
|
url?: string;
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
/**
|
|
21
21
|
* An app configuration as defined by the Swell API. This implies that the
|
|
22
22
|
* app & the configuration are saved to the API.
|
|
23
23
|
*/
|
|
24
|
-
declare abstract class AppConfig {
|
|
24
|
+
export declare abstract class AppConfig {
|
|
25
25
|
appConfigId?: string;
|
|
26
26
|
appPath: string;
|
|
27
27
|
byteSize?: number;
|
|
@@ -53,4 +53,4 @@ declare abstract class AppConfig {
|
|
|
53
53
|
protected abstract preparePostData(postData: any): Promise<any>;
|
|
54
54
|
abstract type: ConfigType;
|
|
55
55
|
}
|
|
56
|
-
export {
|
|
56
|
+
export {};
|
|
@@ -4,14 +4,14 @@ import { detectFilenameMime } from 'mime-detect';
|
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import { bundleFunction } from '../bundle.js';
|
|
7
|
-
import { ConfigPaths, ConfigType, filePathExists, hashFile } from './index.js';
|
|
8
|
-
class IgnoringFileError extends Error {
|
|
7
|
+
import { ConfigPaths, ConfigType, filePathExists, hashFile, } from './index.js';
|
|
8
|
+
export class IgnoringFileError extends Error {
|
|
9
9
|
constructor(message) {
|
|
10
10
|
super(message);
|
|
11
11
|
this.name = 'IgnoringFileError';
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
class FunctionProcessingError extends Error {
|
|
14
|
+
export class FunctionProcessingError extends Error {
|
|
15
15
|
originalError;
|
|
16
16
|
constructor(message, error) {
|
|
17
17
|
super(message);
|
|
@@ -23,7 +23,7 @@ class FunctionProcessingError extends Error {
|
|
|
23
23
|
* An app configuration as defined by the Swell API. This implies that the
|
|
24
24
|
* app & the configuration are saved to the API.
|
|
25
25
|
*/
|
|
26
|
-
class AppConfig {
|
|
26
|
+
export class AppConfig {
|
|
27
27
|
// Used when pushing a theme and the app config is considered
|
|
28
28
|
appConfigId;
|
|
29
29
|
// Full local path of remote AppConfig
|
|
@@ -295,4 +295,3 @@ class AppConfigTheme extends AppConfigDefault {
|
|
|
295
295
|
return postData;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
export { AppConfig, FunctionProcessingError, IgnoringFileError };
|