diff --git a/lib/ditto.ts b/lib/ditto.ts index d4fecfb..6f9de0e 100755 --- a/lib/ditto.ts +++ b/lib/ditto.ts @@ -63,6 +63,11 @@ const COMMANDS: CommandConfig[] = [ { name: "pull", description: "Sync copy from Ditto into the current working directory", + flags: { + "--sample-data": { + description: "Include sample data. Currently only supports variants.", + }, + }, }, { name: "project", @@ -210,7 +215,10 @@ const executeCommand = async ( switch (command) { case "none": case "pull": { - return pull({ meta: processMetaOption(meta) }); + return pull({ + meta: processMetaOption(meta), + includeSampleData: options.sampleData || false, + }); } case "project": case "project add": { diff --git a/lib/http/fetchVariants.ts b/lib/http/fetchVariants.ts index 67e2ba3..5b8fbdf 100644 --- a/lib/http/fetchVariants.ts +++ b/lib/http/fetchVariants.ts @@ -15,7 +15,7 @@ export async function fetchVariants( const { shouldFetchComponentLibrary, validProjects } = source; const config: AxiosRequestConfig = { - params: { ...options?.meta }, + params: { ...options?.meta, showSampleData: options.includeSampleData }, }; // if we're not syncing from the component library, then we pass the project ids diff --git a/lib/pull.ts b/lib/pull.ts index f7dc89f..82acc99 100644 --- a/lib/pull.ts +++ b/lib/pull.ts @@ -327,7 +327,7 @@ async function downloadAndSave( spinner.start(); const [variants, allComponentFoldersResponse] = await Promise.all([ - fetchVariants(source), + fetchVariants(source, options), fetchComponentFolders({}), ]); @@ -578,15 +578,20 @@ async function downloadAndSave( export interface PullOptions { meta?: Record; + includeSampleData?: boolean; } export const pull = async (options?: PullOptions) => { const meta = options ? options.meta : {}; + const includeSampleData = options?.includeSampleData || false const token = config.getToken(consts.CONFIG_FILE, consts.API_HOST); const sourceInformation = config.parseSourceInformation(); try { - return await downloadAndSave(sourceInformation, token, { meta }); + return await downloadAndSave(sourceInformation, token, { + meta, + includeSampleData, + }); } catch (e) { const eventId = Sentry.captureException(e); const eventStr = `\n\nError ID: ${output.info(eventId)}`; diff --git a/package.json b/package.json index bb8642f..8259d88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dittowords/cli", - "version": "4.3.0", + "version": "4.4.0", "description": "Command Line Interface for Ditto (dittowords.com).", "license": "MIT", "main": "bin/index.js",