@swell/cli 2.0.1-alpha.17 → 2.0.1-alpha.18
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 +1 -1
- package/dist/app-command.js +3 -3
- package/dist/commands/app/dev.d.ts +3 -5
- package/dist/commands/app/dev.js +3 -6
- package/dist/commands/app/frontend/deploy.d.ts +1 -3
- package/dist/commands/app/frontend/deploy.js +2 -5
- package/dist/commands/app/frontend/dev.d.ts +4 -6
- package/dist/commands/app/frontend/dev.js +12 -15
- package/dist/commands/app/info.js +1 -3
- package/dist/commands/app/init.js +2 -2
- package/dist/commands/app/install.js +0 -1
- package/dist/commands/app/pull.d.ts +3 -3
- package/dist/commands/app/pull.js +16 -16
- package/dist/commands/app/push.d.ts +4 -4
- package/dist/commands/app/push.js +28 -31
- package/dist/commands/app/release.d.ts +3 -3
- package/dist/commands/app/release.js +43 -45
- package/dist/commands/app/version.d.ts +4 -4
- package/dist/commands/app/version.js +28 -28
- package/dist/commands/create/app.d.ts +15 -15
- package/dist/commands/create/app.js +66 -66
- package/dist/commands/create/frontend.js +4 -7
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +31 -0
- package/dist/commands/login.js +1 -3
- package/dist/commands/logs.js +0 -2
- package/dist/commands/theme/dev.d.ts +6 -8
- package/dist/commands/theme/dev.js +30 -33
- package/dist/commands/theme/init.d.ts +1 -1
- package/dist/commands/theme/init.js +1 -1
- package/dist/commands/theme/pull.d.ts +7 -7
- package/dist/commands/theme/pull.js +21 -21
- package/dist/commands/theme/push.d.ts +7 -7
- package/dist/commands/theme/push.js +24 -27
- package/dist/create-app-command.d.ts +7 -7
- package/dist/create-app-command.js +146 -147
- package/dist/create-config-command.js +0 -2
- package/dist/env/local.d.ts +8 -0
- package/dist/env/local.js +7 -0
- package/dist/env/production.d.ts +8 -0
- package/dist/env/production.js +7 -0
- package/dist/env/review.d.ts +8 -0
- package/dist/env/review.js +7 -0
- package/dist/env/staging.d.ts +8 -0
- package/dist/env/staging.js +7 -0
- package/dist/lib/api.d.ts +3 -3
- package/dist/lib/api.js +35 -35
- package/dist/lib/app-config.d.ts +2 -2
- package/dist/lib/app-config.js +12 -11
- package/dist/lib/apps/app-config.d.ts +19 -19
- package/dist/lib/apps/app-config.js +59 -65
- package/dist/lib/apps/index.d.ts +56 -56
- package/dist/lib/apps/index.js +40 -42
- package/dist/lib/apps/paths.d.ts +1 -1
- package/dist/lib/apps/paths.js +4 -4
- package/dist/lib/config.d.ts +4 -1
- package/dist/lib/config.js +35 -1
- package/dist/lib/constants.js +7 -8
- package/dist/lib/create/index.js +2 -2
- package/dist/lib/stores.d.ts +4 -2
- package/dist/lib/stores.js +4 -2
- package/dist/push-app-command.d.ts +34 -34
- package/dist/push-app-command.js +391 -402
- package/dist/remote-app-command.d.ts +24 -24
- package/dist/remote-app-command.js +245 -259
- package/oclif.manifest.json +152 -119
- package/package.json +2 -1
|
@@ -34,19 +34,6 @@ export default class AppVersion extends PushAppCommand {
|
|
|
34
34
|
},
|
|
35
35
|
}),
|
|
36
36
|
};
|
|
37
|
-
static flags = {
|
|
38
|
-
message: Flags.string({
|
|
39
|
-
char: 'm',
|
|
40
|
-
description: 'description of the changes in this version for internal use',
|
|
41
|
-
}),
|
|
42
|
-
amend: Flags.boolean({
|
|
43
|
-
description: 'amend the description an existing version',
|
|
44
|
-
}),
|
|
45
|
-
'no-git-tag': Flags.boolean({
|
|
46
|
-
description: 'do not create a git tag for this version',
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
static summary = 'Increment the version of your Swell app.';
|
|
50
37
|
static description = `When executed without specifying NEXTVERSION, the command will display the current
|
|
51
38
|
version of your app.
|
|
52
39
|
|
|
@@ -63,6 +50,19 @@ behavior by using the --no-git-tag option.`;
|
|
|
63
50
|
'swell app version minor',
|
|
64
51
|
'swell app version 1.0.0 -m "First release"',
|
|
65
52
|
];
|
|
53
|
+
static flags = {
|
|
54
|
+
amend: Flags.boolean({
|
|
55
|
+
description: 'amend the description an existing version',
|
|
56
|
+
}),
|
|
57
|
+
message: Flags.string({
|
|
58
|
+
char: 'm',
|
|
59
|
+
description: 'description of the changes in this version for internal use',
|
|
60
|
+
}),
|
|
61
|
+
'no-git-tag': Flags.boolean({
|
|
62
|
+
description: 'do not create a git tag for this version',
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
static summary = 'Increment the version of your Swell app.';
|
|
66
66
|
async run() {
|
|
67
67
|
const { args, flags } = await this.parse(AppVersion);
|
|
68
68
|
const { amend, 'no-git-tag': noGitTag } = flags;
|
|
@@ -128,6 +128,21 @@ behavior by using the --no-git-tag option.`;
|
|
|
128
128
|
}
|
|
129
129
|
spinner.succeed(`${style.appConfigValue(this.app.name)} version ${nextVersion} created.`);
|
|
130
130
|
}
|
|
131
|
+
async createRemoteVersion(nextVersion, message, spinner) {
|
|
132
|
+
// update the version on the remote
|
|
133
|
+
const versionResponse = await this.api.post({ adminPath: `/apps/${this.app.id}/versions` }, {
|
|
134
|
+
body: { description: message, version: nextVersion },
|
|
135
|
+
onAsyncGetPath: (response) => ({
|
|
136
|
+
adminPath: `/apps/${this.app.id}/versions/${response.id}`,
|
|
137
|
+
}),
|
|
138
|
+
spinner,
|
|
139
|
+
});
|
|
140
|
+
if (!versionResponse || !versionResponse.version) {
|
|
141
|
+
spinner.fail('Something went wrong.');
|
|
142
|
+
}
|
|
143
|
+
// update the local app config file since remote was successful
|
|
144
|
+
this.swellConfig.set('version', nextVersion);
|
|
145
|
+
}
|
|
131
146
|
async gitCommit(message) {
|
|
132
147
|
// check if there are changes in the app config file
|
|
133
148
|
// if there are no changes, there is nothing to commit
|
|
@@ -147,21 +162,6 @@ behavior by using the --no-git-tag option.`;
|
|
|
147
162
|
// tag the version in git
|
|
148
163
|
await git.spawn(['tag', tag], { cwd: process.cwd() });
|
|
149
164
|
}
|
|
150
|
-
async createRemoteVersion(nextVersion, message, spinner) {
|
|
151
|
-
// update the version on the remote
|
|
152
|
-
const versionResponse = await this.api.post({ adminPath: `/apps/${this.app.id}/versions` }, {
|
|
153
|
-
body: { description: message, version: nextVersion },
|
|
154
|
-
spinner,
|
|
155
|
-
onAsyncGetPath: (response) => ({
|
|
156
|
-
adminPath: `/apps/${this.app.id}/versions/${response.id}`,
|
|
157
|
-
}),
|
|
158
|
-
});
|
|
159
|
-
if (!versionResponse || !versionResponse.version) {
|
|
160
|
-
spinner.fail('Something went wrong.');
|
|
161
|
-
}
|
|
162
|
-
// update the local app config file since remote was successful
|
|
163
|
-
this.swellConfig.set('version', nextVersion);
|
|
164
|
-
}
|
|
165
165
|
validateAndComputeVersion(nextVersion, remoteVersion) {
|
|
166
166
|
let version = nextVersion;
|
|
167
167
|
// compute the value of the next version and check if it's valid
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CreateAppCommand } from '../../create-app-command.js';
|
|
2
2
|
export default class CreateApp extends CreateAppCommand {
|
|
3
|
-
appType: string;
|
|
4
3
|
static args: {
|
|
5
4
|
id: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
5
|
};
|
|
@@ -10,36 +9,37 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
10
9
|
description: string;
|
|
11
10
|
}[];
|
|
12
11
|
static flags: any;
|
|
13
|
-
|
|
14
|
-
createSwellConfig({ inputId,
|
|
12
|
+
appType: string;
|
|
13
|
+
createSwellConfig({ allowOverwrite, inputId, inputStorefrontApp, inputType, inputYes, nestedPath, }: {
|
|
14
|
+
allowOverwrite?: boolean;
|
|
15
15
|
inputId: string;
|
|
16
|
-
inputYes?: boolean;
|
|
17
|
-
inputType?: string;
|
|
18
16
|
inputStorefrontApp?: string;
|
|
19
|
-
|
|
17
|
+
inputType?: string;
|
|
18
|
+
inputYes?: boolean;
|
|
20
19
|
nestedPath?: boolean;
|
|
21
20
|
}): Promise<{
|
|
22
21
|
appId: string;
|
|
22
|
+
config: any;
|
|
23
|
+
installedStorefrontApp: any;
|
|
23
24
|
swellConfigJson: {
|
|
24
|
-
permissions: never[];
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
description: string;
|
|
28
|
-
type: string;
|
|
29
|
-
version: string;
|
|
30
|
-
} | {
|
|
31
25
|
theme: {
|
|
32
26
|
storefront: {
|
|
33
27
|
app: string;
|
|
34
28
|
};
|
|
35
29
|
};
|
|
30
|
+
description: string;
|
|
36
31
|
id: string;
|
|
37
32
|
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
version: string;
|
|
35
|
+
} | {
|
|
36
|
+
permissions: never[];
|
|
38
37
|
description: string;
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
39
40
|
type: string;
|
|
40
41
|
version: string;
|
|
41
42
|
};
|
|
42
|
-
config: any;
|
|
43
|
-
installedStorefrontApp: any;
|
|
44
43
|
} | undefined>;
|
|
44
|
+
run(): Promise<void>;
|
|
45
45
|
}
|
|
@@ -2,12 +2,11 @@ import { confirm, input, select } from '@inquirer/prompts';
|
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import ora from 'ora';
|
|
5
|
-
import {
|
|
5
|
+
import { CreateAppCommand } from '../../create-app-command.js';
|
|
6
|
+
import { newConfig, swellConfigFileExists } from '../../lib/app-config.js';
|
|
6
7
|
import { toAppId, toAppName } from '../../lib/create/index.js';
|
|
7
8
|
import style from '../../lib/style.js';
|
|
8
|
-
import { CreateAppCommand } from '../../create-app-command.js';
|
|
9
9
|
export default class CreateApp extends CreateAppCommand {
|
|
10
|
-
appType = '';
|
|
11
10
|
static args = {
|
|
12
11
|
id: Args.string({
|
|
13
12
|
default: '',
|
|
@@ -34,62 +33,20 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
34
33
|
},
|
|
35
34
|
];
|
|
36
35
|
static flags = {
|
|
37
|
-
type: Flags.string({
|
|
38
|
-
char: 't',
|
|
39
|
-
description: `create a specific app type`,
|
|
40
|
-
options: ['admin', 'integration', 'storefront', 'theme'],
|
|
41
|
-
}),
|
|
42
36
|
pkg: Flags.string({
|
|
43
37
|
char: 'p',
|
|
44
38
|
default: 'npm',
|
|
45
39
|
description: `use npm or yarn to install default dependencies, or none to disable`,
|
|
46
40
|
options: ['npm', 'yarn', 'none'],
|
|
47
41
|
}),
|
|
42
|
+
type: Flags.string({
|
|
43
|
+
char: 't',
|
|
44
|
+
description: `create a specific app type`,
|
|
45
|
+
options: ['admin', 'integration', 'storefront', 'theme'],
|
|
46
|
+
}),
|
|
48
47
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const { id } = args;
|
|
52
|
-
const { pkg, yes } = flags;
|
|
53
|
-
let confirmYes = Boolean(yes && id);
|
|
54
|
-
const createParams = await this.createSwellConfig({
|
|
55
|
-
inputId: id,
|
|
56
|
-
inputYes: confirmYes,
|
|
57
|
-
inputType: flags['type'],
|
|
58
|
-
inputStorefrontApp: flags['storefront-app'],
|
|
59
|
-
});
|
|
60
|
-
if (!createParams) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const { appId, config, installedStorefrontApp } = createParams;
|
|
64
|
-
!confirmYes && this.log();
|
|
65
|
-
const spinner = ora();
|
|
66
|
-
spinner.start('Creating app...');
|
|
67
|
-
if (pkg !== 'none') {
|
|
68
|
-
await this.tryPackageSetup(appId, config, pkg);
|
|
69
|
-
}
|
|
70
|
-
await this.createAppConfigFolders(config);
|
|
71
|
-
spinner.succeed(`${style.appConfigValue(config.get('name'))} app created.\n`);
|
|
72
|
-
let createdFrontend, createdTheme;
|
|
73
|
-
if (installedStorefrontApp) {
|
|
74
|
-
createdTheme = await this.createThemeApp(config, flags, installedStorefrontApp);
|
|
75
|
-
}
|
|
76
|
-
else if (config.get('type') === 'storefront') {
|
|
77
|
-
createdFrontend = await this.createStorefrontApp(config, flags);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
createdFrontend = await this.createFrontendApp(config, flags);
|
|
81
|
-
}
|
|
82
|
-
this.log('\nNext steps:');
|
|
83
|
-
this.log(`Run ${style.command('swell app push')} to push configurations to your test store.`);
|
|
84
|
-
this.log(`Run ${style.command('swell app install')} to install the app in another store or environment.`);
|
|
85
|
-
if (createdFrontend) {
|
|
86
|
-
this.log(`Run ${style.command('swell app frontend dev')} to start a local dev server for your frontend app.`);
|
|
87
|
-
}
|
|
88
|
-
else if (createdTheme) {
|
|
89
|
-
this.log(`Run ${style.command('swell app theme dev')} to start a local dev server for your theme.`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async createSwellConfig({ inputId, inputYes, inputType, inputStorefrontApp, allowOverwrite = true, nestedPath = true, }) {
|
|
48
|
+
appType = '';
|
|
49
|
+
async createSwellConfig({ allowOverwrite = true, inputId, inputStorefrontApp, inputType, inputYes, nestedPath = true, }) {
|
|
93
50
|
let confirmYes = inputYes;
|
|
94
51
|
const type = inputType ||
|
|
95
52
|
(confirmYes
|
|
@@ -143,17 +100,16 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
143
100
|
return;
|
|
144
101
|
}
|
|
145
102
|
storefrontAppId =
|
|
146
|
-
inputStorefrontApp ||
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
103
|
+
inputStorefrontApp ||
|
|
104
|
+
(storefrontInstalledApps.length > 1
|
|
105
|
+
? await select({
|
|
106
|
+
choices: storefrontInstalledApps.map(({ app, id }) => ({
|
|
150
107
|
name: app.name,
|
|
151
108
|
value: id,
|
|
152
109
|
})),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
: storefrontInstalledApps[0].id);
|
|
110
|
+
message: `Which storefront app is your theme for?`,
|
|
111
|
+
})
|
|
112
|
+
: storefrontInstalledApps[0].id);
|
|
157
113
|
installedStorefrontApp = storefrontInstalledApps.find((installedApp) => inputStorefrontApp
|
|
158
114
|
? inputStorefrontApp === installedApp.app_private_id ||
|
|
159
115
|
inputStorefrontApp === installedApp.app_public_id ||
|
|
@@ -165,21 +121,21 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
165
121
|
}
|
|
166
122
|
}
|
|
167
123
|
const swellConfigJson = {
|
|
124
|
+
description,
|
|
168
125
|
id: appId,
|
|
169
126
|
name,
|
|
170
|
-
description,
|
|
171
127
|
type,
|
|
172
128
|
version,
|
|
173
|
-
...(type
|
|
129
|
+
...(type === 'theme'
|
|
174
130
|
? {
|
|
175
|
-
permissions: [],
|
|
176
|
-
}
|
|
177
|
-
: {
|
|
178
131
|
theme: {
|
|
179
132
|
storefront: {
|
|
180
133
|
app: toAppId(installedStorefrontApp.app_private_id),
|
|
181
134
|
},
|
|
182
135
|
},
|
|
136
|
+
}
|
|
137
|
+
: {
|
|
138
|
+
permissions: [],
|
|
183
139
|
}),
|
|
184
140
|
};
|
|
185
141
|
const appPath = path.join(process.cwd(), appId);
|
|
@@ -211,6 +167,50 @@ export default class CreateApp extends CreateAppCommand {
|
|
|
211
167
|
const config = newConfig(nestedPath ? appId : '');
|
|
212
168
|
config.clear();
|
|
213
169
|
config.set(swellConfigJson);
|
|
214
|
-
return { appId,
|
|
170
|
+
return { appId, config, installedStorefrontApp, swellConfigJson };
|
|
171
|
+
}
|
|
172
|
+
async run() {
|
|
173
|
+
const { args, flags } = await this.parse(CreateApp);
|
|
174
|
+
const { id } = args;
|
|
175
|
+
const { pkg, yes } = flags;
|
|
176
|
+
const confirmYes = Boolean(yes && id);
|
|
177
|
+
const createParams = await this.createSwellConfig({
|
|
178
|
+
inputId: id,
|
|
179
|
+
inputStorefrontApp: flags['storefront-app'],
|
|
180
|
+
inputType: flags.type,
|
|
181
|
+
inputYes: confirmYes,
|
|
182
|
+
});
|
|
183
|
+
if (!createParams) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const { appId, config, installedStorefrontApp } = createParams;
|
|
187
|
+
!confirmYes && this.log();
|
|
188
|
+
const spinner = ora();
|
|
189
|
+
spinner.start('Creating app...');
|
|
190
|
+
if (pkg !== 'none') {
|
|
191
|
+
await this.tryPackageSetup(appId, config, pkg);
|
|
192
|
+
}
|
|
193
|
+
await this.createAppConfigFolders(config);
|
|
194
|
+
spinner.succeed(`${style.appConfigValue(config.get('name'))} app created.\n`);
|
|
195
|
+
let createdFrontend;
|
|
196
|
+
let createdTheme;
|
|
197
|
+
if (installedStorefrontApp) {
|
|
198
|
+
createdTheme = await this.createThemeApp(config, flags, installedStorefrontApp);
|
|
199
|
+
}
|
|
200
|
+
else if (config.get('type') === 'storefront') {
|
|
201
|
+
createdFrontend = await this.createStorefrontApp(config, flags);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
createdFrontend = await this.createFrontendApp(config, flags);
|
|
205
|
+
}
|
|
206
|
+
this.log('\nNext steps:');
|
|
207
|
+
this.log(`Run ${style.command('swell app push')} to push configurations to your test store.`);
|
|
208
|
+
this.log(`Run ${style.command('swell app install')} to install the app in another store or environment.`);
|
|
209
|
+
if (createdFrontend) {
|
|
210
|
+
this.log(`Run ${style.command('swell app frontend dev')} to start a local dev server for your frontend app.`);
|
|
211
|
+
}
|
|
212
|
+
else if (createdTheme) {
|
|
213
|
+
this.log(`Run ${style.command('swell app theme dev')} to start a local dev server for your theme.`);
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import ora from 'ora';
|
|
3
|
-
import swellConfig from '../../lib/app-config.js';
|
|
4
3
|
import { CreateAppCommand } from '../../create-app-command.js';
|
|
4
|
+
import swellConfig from '../../lib/app-config.js';
|
|
5
5
|
export default class CreateFrontend extends CreateAppCommand {
|
|
6
6
|
static description = 'Initialize a frontend app framework and folder structure.';
|
|
7
7
|
static examples = [
|
|
@@ -31,11 +31,8 @@ export default class CreateFrontend extends CreateAppCommand {
|
|
|
31
31
|
spinner.fail(`You can't create app frontend in a theme.`);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
else {
|
|
38
|
-
await this.createFrontendApp(newSwellConfig, flags, true);
|
|
39
|
-
}
|
|
34
|
+
await (appType === 'storefront'
|
|
35
|
+
? this.createStorefrontApp(newSwellConfig, flags, true)
|
|
36
|
+
: this.createFrontendApp(newSwellConfig, flags, true));
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config } from '@oclif/core';
|
|
2
|
+
import { SwellCommand } from '../swell-command.js';
|
|
3
|
+
export default class Env extends SwellCommand {
|
|
4
|
+
static args: {
|
|
5
|
+
name: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
reviewBranch: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static hidden: boolean;
|
|
10
|
+
constructor(argv: string[], config: Config);
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { env, setEnv } from '../lib/config.js';
|
|
3
|
+
import style from '../lib/style.js';
|
|
4
|
+
import { SwellCommand } from '../swell-command.js';
|
|
5
|
+
export default class Env extends SwellCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
name: Args.string({
|
|
8
|
+
description: 'name of the environment (production, staging, local, review)',
|
|
9
|
+
}),
|
|
10
|
+
reviewBranch: Args.string({
|
|
11
|
+
description: 'name of a review branch',
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
static description = `Internal: Display the current environment configuration.`;
|
|
15
|
+
static hidden = true;
|
|
16
|
+
constructor(argv, config) {
|
|
17
|
+
super(argv, config);
|
|
18
|
+
this.requiresAuth = false;
|
|
19
|
+
}
|
|
20
|
+
async run() {
|
|
21
|
+
const { args } = await this.parse(Env);
|
|
22
|
+
const { name, reviewBranch } = args;
|
|
23
|
+
if (name) {
|
|
24
|
+
const newEnv = setEnv(name, reviewBranch);
|
|
25
|
+
this.log(`Environment set to ${style.appEnv(name)}:`, JSON.stringify(newEnv, null, 2));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.log('Current environment:', JSON.stringify(env.store, null, 2));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/commands/login.js
CHANGED
|
@@ -61,9 +61,7 @@ have available for logging in to.
|
|
|
61
61
|
* @returns void
|
|
62
62
|
*/
|
|
63
63
|
async getAndSetStoreConfig({ sessionId, storeId, }) {
|
|
64
|
-
const switchResponse = await this.api.post({ adminPath: '/user/switch' },
|
|
65
|
-
// eslint-disable-next-line camelcase
|
|
66
|
-
{ body: { client_id: storeId }, sessionId });
|
|
64
|
+
const switchResponse = await this.api.post({ adminPath: '/user/switch' }, { body: { client_id: storeId }, sessionId });
|
|
67
65
|
// ensure we have the attribute names as we expect before saving
|
|
68
66
|
switchResponse.sessionId = switchResponse.session_id;
|
|
69
67
|
switchResponse.storeId = switchResponse.client_id;
|
package/dist/commands/logs.js
CHANGED
|
@@ -51,12 +51,10 @@ function buildLogRequestBody(flags) {
|
|
|
51
51
|
}
|
|
52
52
|
const { after, before, env, startPolling } = flags;
|
|
53
53
|
if (env) {
|
|
54
|
-
// eslint-disable-next-line camelcase
|
|
55
54
|
andConditions.push({ environment_id: env });
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
58
57
|
// Default to test env
|
|
59
|
-
// eslint-disable-next-line camelcase
|
|
60
58
|
andConditions.push({ environment_id: 'test' });
|
|
61
59
|
}
|
|
62
60
|
// if we are polling, we want to get logs after the last date we received
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { Config } from '@oclif/core';
|
|
2
1
|
import { PushAppCommand } from '../../push-app-command.js';
|
|
3
2
|
export default class AppThemeDev extends PushAppCommand {
|
|
4
|
-
appType: string;
|
|
5
|
-
static summary: string;
|
|
6
3
|
static examples: string[];
|
|
7
4
|
static flags: {
|
|
8
|
-
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
10
|
-
local: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
5
|
bundle: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
6
|
+
local: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
7
|
'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
8
|
+
'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
10
|
};
|
|
14
11
|
static orientation: {
|
|
15
12
|
env: string;
|
|
16
13
|
};
|
|
17
|
-
|
|
14
|
+
static summary: string;
|
|
15
|
+
appType: string;
|
|
16
|
+
logAppLocalUrl(storeId: string, sessionId: string): void;
|
|
18
17
|
run(): Promise<void>;
|
|
19
18
|
private findAndInstallDependencies;
|
|
20
19
|
private findAndTryScriptCommands;
|
|
21
20
|
private startThemeDevServer;
|
|
22
|
-
logAppLocalUrl(storeId: string, sessionId: string): void;
|
|
23
21
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import ora from 'ora';
|
|
3
|
-
import BrowserSync from 'browser-sync';
|
|
4
1
|
import { Flags } from '@oclif/core';
|
|
5
|
-
import
|
|
6
|
-
import { spawn, execSync } from 'child_process';
|
|
2
|
+
import BrowserSync from 'browser-sync';
|
|
7
3
|
import { findUp } from 'find-up';
|
|
4
|
+
import getPort, { portNumbers } from 'get-port';
|
|
5
|
+
import { execSync, spawn } from 'node:child_process';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import ora from 'ora';
|
|
8
8
|
import { default as localConfig } from '../../lib/config.js';
|
|
9
|
-
import { PushAppCommand } from '../../push-app-command.js';
|
|
10
9
|
import style from '../../lib/style.js';
|
|
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';
|
|
14
|
-
static summary = `Run a theme in dev mode from your local machine.`;
|
|
15
13
|
static examples = [
|
|
16
14
|
'swell theme dev',
|
|
17
15
|
'swell theme dev --local',
|
|
@@ -20,28 +18,30 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
20
18
|
'swell theme dev --storefront-id <id>',
|
|
21
19
|
];
|
|
22
20
|
static flags = {
|
|
23
|
-
|
|
24
|
-
description: '
|
|
25
|
-
}),
|
|
26
|
-
'storefront-select': Flags.boolean({
|
|
27
|
-
description: 'prompt to select a storefront to preview and push theme files to',
|
|
28
|
-
default: false,
|
|
21
|
+
bundle: Flags.boolean({
|
|
22
|
+
description: 'bundle assets',
|
|
29
23
|
}),
|
|
30
24
|
local: Flags.boolean({
|
|
31
25
|
description: 'connect to a running local storefront app dev server',
|
|
32
26
|
}),
|
|
33
|
-
bundle: Flags.boolean({
|
|
34
|
-
description: 'bundle assets',
|
|
35
|
-
}),
|
|
36
27
|
'no-push': Flags.boolean({
|
|
37
28
|
description: 'skip pushing theme files initially',
|
|
38
29
|
}),
|
|
30
|
+
'storefront-id': Flags.string({
|
|
31
|
+
description: 'identify a storefront to preview and push theme files to',
|
|
32
|
+
}),
|
|
33
|
+
'storefront-select': Flags.boolean({
|
|
34
|
+
default: false,
|
|
35
|
+
description: 'prompt to select a storefront to preview and push theme files to',
|
|
36
|
+
}),
|
|
39
37
|
};
|
|
40
38
|
static orientation = {
|
|
41
39
|
env: 'test',
|
|
42
40
|
};
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
static summary = `Run a theme in dev mode from your local machine.`;
|
|
42
|
+
appType = 'theme';
|
|
43
|
+
logAppLocalUrl(storeId, sessionId) {
|
|
44
|
+
this.log(`View it at ${style.link(this.localFrontendUrl(storeId, sessionId))}\n`);
|
|
45
45
|
}
|
|
46
46
|
async run() {
|
|
47
47
|
const { flags } = await this.parse(AppThemeDev);
|
|
@@ -79,7 +79,7 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
79
79
|
spinner.succeed('Dependencies installed');
|
|
80
80
|
return packageJsonPath;
|
|
81
81
|
}
|
|
82
|
-
catch
|
|
82
|
+
catch {
|
|
83
83
|
spinner.fail('Error locating package.json. Skipping bundle process.');
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
@@ -99,18 +99,18 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
const childProcess = spawn('npm', ['run', scriptName], {
|
|
102
|
-
stdio: 'pipe',
|
|
103
|
-
shell: true,
|
|
104
102
|
env: { ...process.env, BROWSERSLIST_IGNORE_OLD_DATA: 'true' },
|
|
103
|
+
shell: true,
|
|
104
|
+
stdio: 'pipe',
|
|
105
105
|
});
|
|
106
106
|
childProcess.stdout.on('data', (data) => {
|
|
107
107
|
const lines = data.toString().split(/\r?\n/);
|
|
108
|
-
|
|
108
|
+
for (const line of lines) {
|
|
109
109
|
const trimmedLine = line.trim();
|
|
110
110
|
if (trimmedLine) {
|
|
111
111
|
console.log(`${style.success('📦')} ${trimmedLine}`);
|
|
112
112
|
}
|
|
113
|
-
}
|
|
113
|
+
}
|
|
114
114
|
});
|
|
115
115
|
childProcess.on('exit', (code) => {
|
|
116
116
|
if (code === 0) {
|
|
@@ -121,8 +121,8 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
catch (
|
|
125
|
-
console.error('Error processing package.json:',
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error('Error processing package.json:', error);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
async startThemeDevServer(local) {
|
|
@@ -142,18 +142,18 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
142
142
|
: this.storefrontFrontendUrl(currentStore, this.storefront, undefined, true);
|
|
143
143
|
const bs = BrowserSync.create();
|
|
144
144
|
bs.init({
|
|
145
|
-
|
|
145
|
+
logLevel: 'silent',
|
|
146
146
|
notify: false,
|
|
147
|
+
open: false,
|
|
147
148
|
proxy: {
|
|
148
|
-
target: storefrontUrl,
|
|
149
149
|
proxyReq: [
|
|
150
150
|
(proxyReq) => {
|
|
151
151
|
proxyReq.setHeader('swell-request-id', `${currentStore}_${Date.now()}`);
|
|
152
152
|
},
|
|
153
153
|
],
|
|
154
|
+
target: storefrontUrl,
|
|
154
155
|
},
|
|
155
|
-
|
|
156
|
-
open: false,
|
|
156
|
+
ui: false,
|
|
157
157
|
});
|
|
158
158
|
await this.watchForChanges({
|
|
159
159
|
onChange: () => bs.reload(),
|
|
@@ -161,7 +161,4 @@ export default class AppThemeDev extends PushAppCommand {
|
|
|
161
161
|
spinner.stop();
|
|
162
162
|
this.log(`Watching for changes. View your theme at ${style.link(`http://localhost:${freePort}`)}\n`);
|
|
163
163
|
}
|
|
164
|
-
logAppLocalUrl(storeId, sessionId) {
|
|
165
|
-
this.log(`View it at ${style.link(this.localFrontendUrl(storeId, sessionId))}\n`);
|
|
166
|
-
}
|
|
167
164
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import InitApp from '../app/init.js';
|
|
2
2
|
export default class InitTheme extends InitApp {
|
|
3
|
-
appType = 'theme';
|
|
4
3
|
static description = 'Initialize theme swell.json in the current directory.';
|
|
5
4
|
static examples = [
|
|
6
5
|
{
|
|
@@ -12,4 +11,5 @@ export default class InitTheme extends InitApp {
|
|
|
12
11
|
description: 'Initialize theme and accept all default values.',
|
|
13
12
|
},
|
|
14
13
|
];
|
|
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;
|
|
4
3
|
static args: {
|
|
5
4
|
appId: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
5
|
targetPath: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
7
6
|
};
|
|
7
|
+
static delayOrientation: boolean;
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
8
10
|
static flags: {
|
|
9
11
|
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
10
|
-
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
|
-
'storefront-select': 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
|
+
'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
+
'sync-app': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
15
|
};
|
|
14
|
-
static summary: string;
|
|
15
|
-
static description: string;
|
|
16
|
-
static examples: string[];
|
|
17
16
|
static orientation: {};
|
|
18
|
-
static
|
|
17
|
+
static summary: string;
|
|
18
|
+
appType: string;
|
|
19
19
|
run(): Promise<void>;
|
|
20
20
|
}
|