ShtukbaseStandard
файл пакета→ .shtukbase/packages/live/actions/app.ts

actions/app.ts

21 строка, 1.1 КБ.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. // Action `app [path.html]`: puts the example interactive page (a task board with buttons) into the project,
  2. // by default at work/tasks-app.html. An existing file is never overwritten.
  3. import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
  4. import { dirname, join, resolve, sep } from 'node:path';
  5. const target = (process.argv[2] ?? 'work/tasks-app.html').replace(/^\/+/, '');
  6. const root = process.cwd();
  7. const file = resolve(root, target);
  8. if (!file.startsWith(root + sep) || !file.endsWith('.html')) {
  9. console.error(`path "${target}" does not fit: it must be an .html file inside the project`);
  10. process.exit(2);
  11. }
  12. if (existsSync(file)) {
  13. console.error(`${target} already exists: not overwriting`);
  14. process.exit(1);
  15. }
  16. mkdirSync(dirname(file), { recursive: true });
  17. copyFileSync(join(import.meta.dir, '..', 'templates', 'tasks-app.html'), file);
  18. console.log(`the example is in ${target}`);
  19. console.log('Open it through the live server link with the token: shtuk run live serve.');
  20. console.log('The "Check project" button needs the line "shtuk check" in run: of the page /base/live.md.');