@swell/cli
Version:
Swell's command line interface/utility
69 lines (66 loc) • 2.49 kB
JavaScript
import { Args, Flags } from '@oclif/core';
import { ThemeConfigPaths } from '../../lib/apps/index.js';
import style from '../../lib/style.js';
import AppPull from '../app/pull.js';
export default class AppThemePull extends AppPull {
appType = 'theme';
static args = {
appId: Args.string({
default: '',
description: 'theme app id to pull',
}),
targetPath: Args.string({
default: '',
description: 'path to download theme files into',
}),
};
static description = `Pull all theme files, a specific file, or a specific configuration
type from a theme in your store's test environment to your local machine.
If APPID is not specified, you will be prompted with a list of themes to choose from.
Theme file directories:
${Object.values(ThemeConfigPaths)
.map((dir) => style.path(`${dir}/`))
.join('\n')}`;
static examples = [
'swell theme pull',
'swell theme pull mytheme',
'swell theme pull mytheme mytheme-folder',
'swell theme pull --force',
'swell theme pull --storefront-select',
'swell theme pull --storefront-id <id>',
];
static flags = {
force: Flags.boolean({
default: false,
description: 'force pull all theme files',
}),
'storefront-id': Flags.string({
description: 'identify a storefront to pull theme files from',
}),
'storefront-select': Flags.boolean({
default: false,
description: 'prompt to select a storefront to pull theme files to',
}),
env: Flags.string({
char: 'e',
description: 'target environment to pull from, defaults to live',
}),
'sync-app': Flags.boolean({
default: false,
description: 'pull app files in addition to theme files to',
}),
};
static summary = 'Pull theme files from Swell to your local machine.';
static delayOrientation = true;
async run() {
const { args, flags } = await this.parse(AppThemePull);
const { force } = flags;
this.themeSyncApp = flags['sync-app'];
await this.ensureLoggedIn();
await this.getStorefrontToPull(args, flags);
await this.logOrientation();
const { pulled, removed } = await this.pullAppConfigs(force);
this.logPulledChanges(pulled, removed);
this.saveCurrentStorefront();
}
}