Something went wrong. Try again.
Dedicated SSR (Server-side-rendered) Astro native Headless CMS, build from the ground up for the Astro community and by Astro community memb github.com/withstudiocms/studiocms
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// @ts-checkimport fs from 'node:fs/promises';import path from 'node:path';import { fileURLToPath } from 'node:url';import { glob } from 'tinyglobby';
/* This file updates the snapshots templates in `templates/*` to match the current state of the templates. This should be run after updating or adding new templates to ensure the snapshots are up to date.*/
const rootUrl = new URL('..', import.meta.url);
// Update all templates' package.jsonconst templateDirs = await glob('templates/*', { onlyDirectories: true, cwd: fileURLToPath(rootUrl),});
/** * @type {import("../packages/create-studiocms/src/types").TemplateOptions} */const templateSnapshots = [];
for (const templateDir of templateDirs) { const packageJsonPath = path.join(templateDir, './package.json'); const packageJson = await readAndParsePackageJson(packageJsonPath); if (!packageJson) continue;
// Update the template snapshot if (packageJson.studiocms_template) { templateSnapshots.push({ value: packageJson.studiocms_template.value, label: packageJson.studiocms_template.label, hint: packageJson.studiocms_template.hint, }); }}
// Update the templates.json file in create-studiocmsconst createStudiocmsTemplatesJsonPath = new URL( '../packages/create-studiocms/src/templates.json', import.meta.url);await fs.writeFile( createStudiocmsTemplatesJsonPath, `${JSON.stringify(templateSnapshots, null, 2)}\n`);
/** * @param {string} packageJsonPath * @returns {Promise<Record<string, any> | undefined>} */async function readAndParsePackageJson(packageJsonPath) { try { return JSON.parse(await fs.readFile(packageJsonPath, 'utf-8')); } catch {}}