@tideworthy/tidysites 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/tidysites.mjs +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ nothing else; it lives in `.tidysites/key`, which is kept out of git.
|
|
|
28
28
|
| `tidysites schema [type or collection]` | the section types and layouts, or one type's or collection's fields |
|
|
29
29
|
| `tidysites gallery [type]` | a screenshot of every section type and layout in this website's theme, or the first screen of one type |
|
|
30
30
|
| `tidysites fetch <url> [--out dir]` | a page of the site being ported: cleaned HTML, its outline (headings, navigation, images, phones, fonts, colours) and its stylesheets |
|
|
31
|
+
| `tidysites rm <collection>/<slug> ...` | delete entry files with their sidecars (`services/*` for every entry of a collection); `push --prune` then removes them from the website |
|
|
31
32
|
| `tidysites publish --yes` | the live site becomes a copy of the preview site |
|
|
32
33
|
|
|
33
34
|
A section keeps its type with its key: to replace an intro with a row, give the row its own `_key`
|
|
@@ -50,7 +51,7 @@ menus/<name>.json a menu as a tree: { "label", "items": [{ "label",
|
|
|
50
51
|
|
|
51
52
|
A new entry is a new `<collection>/<slug>.json` with at least `"data"`; the
|
|
52
53
|
slug is the file name, the status is `published` unless the file says
|
|
53
|
-
`draft`. Delete a file and `push --prune` removes the entry. A field taken
|
|
54
|
+
`draft`. Delete a file (`tidysites rm services/old-one`, or `services/*` for all) and `push --prune` removes the entry. A field taken
|
|
54
55
|
out of a file is cleared on the website at the next push. `id` and
|
|
55
56
|
`updated_at` are the website's; leave them as pulled. A pull never overwrites
|
|
56
57
|
a file you changed and have not pushed; it keeps the file and the difference
|
package/bin/tidysites.mjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* schema [name] section types and layouts, or one type's or collection's fields
|
|
14
14
|
* gallery [type] screenshot of every section type in this theme, or the first screen of one type
|
|
15
15
|
* fetch <url> [--out dir] a page of the site being ported: cleaned HTML and its outline
|
|
16
|
+
* rm <collection>/<slug> ... delete entry files (globs allowed: services/*); push --prune then removes them from the website
|
|
16
17
|
* publish --yes the live site becomes a copy of the preview site
|
|
17
18
|
*
|
|
18
19
|
* The site is the remote: pull, edit, push. A push that would overwrite an
|
|
@@ -465,6 +466,32 @@ async function fetchCmd(ctx) {
|
|
|
465
466
|
say(`Saved to ${relative(process.cwd(), outDir)}/: ${base}.html (cleaned), ${base}.raw.html, ${base}.outline.json${cssTexts.length ? `, ${cssTexts.length} stylesheet${cssTexts.length === 1 ? '' : 's'}` : ''}`);
|
|
466
467
|
}
|
|
467
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Delete entry files inside the folder, with their sidecars, so nobody has to reach for the shell's rm (which a
|
|
471
|
+
* harness may stop to ask about). Takes collection/slug paths; a trailing * takes every entry of the collection.
|
|
472
|
+
*/
|
|
473
|
+
function rmCmd({ dir }) {
|
|
474
|
+
if (!positional.length) fail('Usage: tidysites rm <collection>/<slug> [...] (services/* for every entry of a collection)');
|
|
475
|
+
let removed = 0;
|
|
476
|
+
for (const arg of positional) {
|
|
477
|
+
const m = /^([a-z][a-z0-9_]*)\/(\*|[A-Za-z0-9][A-Za-z0-9_-]*)(?:\.json)?$/.exec(arg.replace(/^\.\//, ''));
|
|
478
|
+
if (!m) fail(`${arg}: write collection/slug or collection/*`);
|
|
479
|
+
const [, collection, slug] = m;
|
|
480
|
+
const colDir = join(dir, collection);
|
|
481
|
+
if (!existsSync(colDir)) { say(`${collection}/: no such collection folder`); continue; }
|
|
482
|
+
const slugs = slug === '*' ? readdirSync(colDir).filter((f) => f.endsWith('.json')).map((f) => f.slice(0, -5)) : [slug];
|
|
483
|
+
for (const sl of slugs) {
|
|
484
|
+
let hit = false;
|
|
485
|
+
for (const ext of ['json', ...Object.keys(SIDECARS[collection] ?? SIDECARS.default)]) {
|
|
486
|
+
const f = join(colDir, `${sl}.${ext}`);
|
|
487
|
+
if (existsSync(f)) { rmSync(f); hit = true; }
|
|
488
|
+
}
|
|
489
|
+
if (hit) { removed++; say(`- ${collection}/${sl}`); } else say(`${collection}/${sl}: no such entry file`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
say(`${removed} entr${removed === 1 ? 'y' : 'ies'} removed from the folder; \`tidysites push --prune\` removes them from the website.`);
|
|
493
|
+
}
|
|
494
|
+
|
|
468
495
|
async function publish(ctx) {
|
|
469
496
|
if (!flags.yes) fail('Publishing makes the live site a copy of the preview site. Look at it first (`tidysites shot /`), then run `tidysites publish --yes`.');
|
|
470
497
|
const { json, text } = await tool(ctx.cfg, 'publish_website', { site_id: ctx.cfg.site });
|
|
@@ -524,6 +551,8 @@ async function main() {
|
|
|
524
551
|
return schema(config());
|
|
525
552
|
case 'fetch':
|
|
526
553
|
return fetchCmd(config(false));
|
|
554
|
+
case 'rm':
|
|
555
|
+
return rmCmd(config());
|
|
527
556
|
case 'publish':
|
|
528
557
|
return publish(config());
|
|
529
558
|
case 'help':
|
package/package.json
CHANGED