groton-school / knowledgebase

Knowledgebase website
https://kb.groton.org
GNU General Public License v3.0
0 stars 0 forks source link

this approach could leave stranded values in SCSS that have been deleted from co... #44

Closed github-actions[bot] closed 1 month ago

github-actions[bot] commented 1 month ago

https://github.com/groton-school/knowledgebase/blob/fa99cc68e5464aa46491f32b59f89f5684ad47b3/apps/ui/bin/sync-config.ts#L32


    return config;
  }
);

function quoted(key: string, value: string = '') {
  switch (key) {
    case 'navbarColor':
      return value;
    default:
      return `"${value}"`;
  }
}

// FIXME this approach could leave stranded values in SCSS that have been deleted from config
const spinner = cli.spinner();
const pathToScss = path.resolve(__dirname, '../src/config.scss');
spinner.start(`Updating ${cli.colors.url(pathToScss)}`);
if (config.ui?.site) {
  fs.writeFileSync(
    pathToScss,
    Object.keys(config.ui.site || [])
      .map(
        (key) =>
          `$${key}: ${quoted(
            key,
            config.ui!.site![key as keyof typeof config.ui.site]
          )};`
      )
      .join('\n')
  );
}
spinner.succeed(`Configuration synced to ${cli.colors.url(pathToScss)}`);
battis commented 1 month ago

No, it couldn't, since the SCSS file is rewritten in its entirety.