@swell/cli 2.0.10 → 2.0.12
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 +1 -1
- package/dist/commands/app/dev.js +1 -1
- 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 +1 -1
- package/dist/commands/app/release.d.ts +3 -0
- package/dist/commands/app/release.js +11 -2
- package/dist/commands/app/version.d.ts +4 -0
- package/dist/commands/app/version.js +17 -9
- package/dist/commands/login.js +1 -1
- package/dist/commands/theme/dev.d.ts +1 -3
- package/dist/commands/theme/dev.js +12 -6
- package/dist/commands/theme/pull.d.ts +1 -2
- package/dist/commands/theme/pull.js +4 -2
- package/dist/commands/theme/push.d.ts +1 -2
- package/dist/commands/theme/push.js +17 -4
- 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 +112 -61
- package/dist/remote-app-command.d.ts +1 -1
- package/dist/remote-app-command.js +7 -7
- package/oclif.manifest.json +59 -10
- 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,6 +7,7 @@ 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 delayOrientation: boolean;
|
|
11
11
|
static orientation: {
|
|
12
12
|
env: string;
|
|
13
13
|
};
|
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,6 +17,7 @@ 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 delayOrientation = true;
|
|
21
21
|
static orientation = {
|
|
22
22
|
env: 'test',
|
|
23
23
|
};
|
|
@@ -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,11 +3,13 @@ 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
|
|
9
|
+
static delayOrientation: boolean;
|
|
10
|
+
static orientation: {
|
|
11
|
+
env: string;
|
|
12
|
+
};
|
|
11
13
|
static summary: string;
|
|
12
14
|
resolvePushPaths(file: string): {
|
|
13
15
|
filePath: 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,6 +38,7 @@ ${Object.values(ConfigPaths)
|
|
|
39
38
|
description: 'skip deploying app frontend',
|
|
40
39
|
}),
|
|
41
40
|
};
|
|
41
|
+
static delayOrientation = true;
|
|
42
42
|
static orientation = {
|
|
43
43
|
env: 'test',
|
|
44
44
|
};
|
|
@@ -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;
|
|
@@ -32,6 +32,7 @@ The app must be connected to a partner account with access to publish.`;
|
|
|
32
32
|
'swell app release',
|
|
33
33
|
'swell app release 2.0.0',
|
|
34
34
|
'swell app release 2.0.0 --amend --release-notes ./releases/v2.0.0.md',
|
|
35
|
+
'swell app release 2.0.0 -y',
|
|
35
36
|
];
|
|
36
37
|
static flags = {
|
|
37
38
|
amend: Flags.boolean({
|
|
@@ -50,11 +51,18 @@ The app must be connected to a partner account with access to publish.`;
|
|
|
50
51
|
'release-notes': Flags.string({
|
|
51
52
|
description: 'relative path to a file containing release notes',
|
|
52
53
|
}),
|
|
54
|
+
yes: Flags.boolean({
|
|
55
|
+
char: 'y',
|
|
56
|
+
description: 'skip confirmation prompt',
|
|
57
|
+
}),
|
|
53
58
|
};
|
|
54
59
|
static summary = 'Release a new version of your an app for publishing to the App Store.';
|
|
60
|
+
static orientation = {
|
|
61
|
+
env: 'test',
|
|
62
|
+
};
|
|
55
63
|
async run() {
|
|
56
64
|
const { args, flags } = await this.parse(AppRelease);
|
|
57
|
-
const { amend, message, 'not-supported': notSupported, 'release-notes': releaseNotesFile, } = flags;
|
|
65
|
+
const { amend, message, 'not-supported': notSupported, 'release-notes': releaseNotesFile, yes, } = flags;
|
|
58
66
|
if (!(await this.ensureAppExists(undefined, false))) {
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
@@ -83,7 +91,7 @@ The app must be connected to a partner account with access to publish.`;
|
|
|
83
91
|
? true
|
|
84
92
|
: appVersion.supported,
|
|
85
93
|
};
|
|
86
|
-
if (!amend) {
|
|
94
|
+
if (!amend && !yes) {
|
|
87
95
|
const continueVersion = await confirm({
|
|
88
96
|
message: `Release ${style.appConfigValue(this.app.name)} version ${appVersion.version}?`,
|
|
89
97
|
});
|
|
@@ -135,6 +143,7 @@ The app must be connected to a partner account with access to publish.`;
|
|
|
135
143
|
version,
|
|
136
144
|
...(flags.message ? [`-m ${JSON.stringify(flags.message)}`] : []),
|
|
137
145
|
...(flags['no-git-tag'] ? ['--no-git-tag'] : []),
|
|
146
|
+
...(flags.yes ? ['-y'] : []),
|
|
138
147
|
]);
|
|
139
148
|
this.log();
|
|
140
149
|
appVersion = await this.getVersion(version);
|
|
@@ -9,8 +9,12 @@ export default class AppVersion extends PushAppCommand {
|
|
|
9
9
|
amend: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
10
10
|
message: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
11
|
'no-git-tag': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
13
14
|
static summary: string;
|
|
15
|
+
static orientation: {
|
|
16
|
+
env: string;
|
|
17
|
+
};
|
|
14
18
|
run(): Promise<void>;
|
|
15
19
|
private createRemoteVersion;
|
|
16
20
|
private gitCommit;
|
|
@@ -49,6 +49,7 @@ behavior by using the --no-git-tag option.`;
|
|
|
49
49
|
'swell app version',
|
|
50
50
|
'swell app version minor',
|
|
51
51
|
'swell app version 1.0.0 -m "First release"',
|
|
52
|
+
'swell app version patch -y',
|
|
52
53
|
];
|
|
53
54
|
static flags = {
|
|
54
55
|
amend: Flags.boolean({
|
|
@@ -61,11 +62,18 @@ behavior by using the --no-git-tag option.`;
|
|
|
61
62
|
'no-git-tag': Flags.boolean({
|
|
62
63
|
description: 'do not create a git tag for this version',
|
|
63
64
|
}),
|
|
65
|
+
yes: Flags.boolean({
|
|
66
|
+
char: 'y',
|
|
67
|
+
description: 'skip confirmation prompt',
|
|
68
|
+
}),
|
|
64
69
|
};
|
|
65
70
|
static summary = 'Increment the version of your Swell app.';
|
|
71
|
+
static orientation = {
|
|
72
|
+
env: 'test',
|
|
73
|
+
};
|
|
66
74
|
async run() {
|
|
67
75
|
const { args, flags } = await this.parse(AppVersion);
|
|
68
|
-
const { amend, 'no-git-tag': noGitTag } = flags;
|
|
76
|
+
const { amend, 'no-git-tag': noGitTag, yes } = flags;
|
|
69
77
|
let { message } = flags;
|
|
70
78
|
let { nextVersion } = args;
|
|
71
79
|
if (!(await this.ensureAppExists(undefined, false))) {
|
|
@@ -99,9 +107,7 @@ behavior by using the --no-git-tag option.`;
|
|
|
99
107
|
}
|
|
100
108
|
return;
|
|
101
109
|
}
|
|
102
|
-
|
|
103
|
-
nextVersion = this.validateAndComputeVersion(nextVersion, remoteVersion);
|
|
104
|
-
}
|
|
110
|
+
nextVersion = this.validateAndComputeVersion(nextVersion, remoteVersion);
|
|
105
111
|
await this.pushAppConfigs();
|
|
106
112
|
await this.deployAppFrontend(false, false);
|
|
107
113
|
if (!message) {
|
|
@@ -109,11 +115,13 @@ behavior by using the --no-git-tag option.`;
|
|
|
109
115
|
message: `Describe the changes in version ${nextVersion}:`,
|
|
110
116
|
});
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
if (!yes) {
|
|
119
|
+
const continueVersion = await confirm({
|
|
120
|
+
message: `Create ${style.appConfigValue(this.app.name)} version ${nextVersion}?`,
|
|
121
|
+
});
|
|
122
|
+
if (!continueVersion) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
if (!message) {
|
|
119
127
|
message = nextVersion;
|
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);
|
|
@@ -8,9 +8,7 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
8
8
|
'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
9
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
10
|
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
|
-
|
|
12
|
-
static orientation: {
|
|
13
|
-
env: string;
|
|
11
|
+
env: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
12
|
};
|
|
15
13
|
static summary: string;
|
|
16
14
|
appType: string;
|
|
@@ -38,9 +38,10 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
38
38
|
default: false,
|
|
39
39
|
description: 'prompt to select a storefront to preview and push theme files to',
|
|
40
40
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
env: Flags.string({
|
|
42
|
+
char: 'e',
|
|
43
|
+
description: 'target environment to push to, defaults to live',
|
|
44
|
+
}),
|
|
44
45
|
};
|
|
45
46
|
static summary = `Run a theme in dev mode from your local machine.`;
|
|
46
47
|
appType = 'theme';
|
|
@@ -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() {
|
|
@@ -4,16 +4,15 @@ export default class AppThemePull extends AppPull {
|
|
|
4
4
|
appId: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
5
|
targetPath: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
|
-
static delayOrientation: boolean;
|
|
8
7
|
static description: string;
|
|
9
8
|
static examples: string[];
|
|
10
9
|
static flags: {
|
|
11
10
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
11
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
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>;
|
|
14
14
|
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
15
|
};
|
|
16
|
-
static orientation: {};
|
|
17
16
|
static summary: string;
|
|
18
17
|
appType: string;
|
|
19
18
|
run(): Promise<void>;
|
|
@@ -13,7 +13,6 @@ export default class AppThemePull extends AppPull {
|
|
|
13
13
|
description: 'path to download theme files into',
|
|
14
14
|
}),
|
|
15
15
|
};
|
|
16
|
-
static delayOrientation = true;
|
|
17
16
|
static description = `Pull all theme files, a specific file, or a specific configuration
|
|
18
17
|
type from a theme in your store's test environment to your local machine.
|
|
19
18
|
|
|
@@ -43,12 +42,15 @@ ${Object.values(ThemeConfigPaths)
|
|
|
43
42
|
default: false,
|
|
44
43
|
description: 'prompt to select a storefront to pull theme files to',
|
|
45
44
|
}),
|
|
45
|
+
env: Flags.string({
|
|
46
|
+
char: 'e',
|
|
47
|
+
description: 'target environment to pull from, defaults to live',
|
|
48
|
+
}),
|
|
46
49
|
'sync-app': Flags.boolean({
|
|
47
50
|
default: false,
|
|
48
51
|
description: 'pull app files in addition to theme files to',
|
|
49
52
|
}),
|
|
50
53
|
};
|
|
51
|
-
static orientation = {};
|
|
52
54
|
static summary = 'Pull theme files from Swell to your local machine.';
|
|
53
55
|
appType = 'theme';
|
|
54
56
|
async run() {
|
|
@@ -3,16 +3,15 @@ export default class AppThemePush extends AppPush {
|
|
|
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: {
|
|
10
9
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
10
|
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
11
|
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
env: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
13
|
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
14
|
};
|
|
15
|
-
static orientation: {};
|
|
16
15
|
static summary: string;
|
|
17
16
|
appType: string;
|
|
18
17
|
run(): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
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 {
|
|
@@ -9,7 +10,6 @@ export default class AppThemePush extends AppPush {
|
|
|
9
10
|
description: 'relative path to a configuration file or directory to push',
|
|
10
11
|
}),
|
|
11
12
|
};
|
|
12
|
-
static delayOrientation = true;
|
|
13
13
|
static description = `Push all theme files, a specific file, or a specific configuration
|
|
14
14
|
type to an theme in your store's test environment.
|
|
15
15
|
|
|
@@ -45,12 +45,15 @@ ${Object.values(ThemeConfigPaths)
|
|
|
45
45
|
default: false,
|
|
46
46
|
description: 'prompt to select a storefront to push theme files to',
|
|
47
47
|
}),
|
|
48
|
+
env: Flags.string({
|
|
49
|
+
char: 'e',
|
|
50
|
+
description: 'target environment to push to, defaults to live',
|
|
51
|
+
}),
|
|
48
52
|
'sync-app': Flags.boolean({
|
|
49
53
|
default: false,
|
|
50
54
|
description: 'push app files in addition to theme files',
|
|
51
55
|
}),
|
|
52
56
|
};
|
|
53
|
-
static orientation = {};
|
|
54
57
|
static summary = 'Push local files to your Swell theme.';
|
|
55
58
|
appType = 'theme';
|
|
56
59
|
async run() {
|
|
@@ -58,6 +61,15 @@ ${Object.values(ThemeConfigPaths)
|
|
|
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 };
|