MCPcopy Create free account
hub / github.com/bigcommerce/stencil-cli / getSchema

Method getSchema

lib/theme-config.js:219–238  ·  view source on GitHub ↗

* Scans the theme template directory for theme settings that need force reload * * @returns {Object}

()

Source from the content-addressed store, hash-verified

217 * @returns {Object}
218 */
219 async getSchema() {
220 if (!fs.existsSync(this.schemaPath)) {
221 return [];
222 }
223 const themeSchema = await parseJsonFile(this.schemaPath);
224 if (!Array.isArray(themeSchema)) {
225 return [];
226 }
227 const files = await promisify(glob)(Path.join(this.themePath, 'templates/**/*.html'));
228 const themeSettings = await Promise.all(files.map(this._fetchThemeSettings));
229 const forceReloadIds = themeSettings.reduce((res, item) => ({ ...res, ...item }), {});
230 for (const themeSchemaItem of themeSchema) {
231 for (const item of themeSchemaItem.settings) {
232 if (forceReloadIds[item.id]) {
233 item.force_reload = true;
234 }
235 }
236 }
237 return themeSchema;
238 }
239
240 /**
241 * Get Schema Translations

Callers 2

assembleSchemaMethod · 0.80

Calls 1

parseJsonFileFunction · 0.90

Tested by

no test coverage detected