@usequeek/create-theme 0.3.7 → 0.4.2
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 +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/naming.d.ts +12 -4
- package/dist/naming.js +8 -5
- package/dist/prompts.js +1 -1
- package/dist/rename.d.ts +10 -4
- package/dist/rename.js +53 -8
- package/dist/setup.js +14 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ and with no folder the folder is named after the theme (my-theme with --yes or n
|
|
|
16
16
|
|
|
17
17
|
--name <text> theme name (default: the folder name)
|
|
18
18
|
--templates <keys> businesses to make templates for, comma-separated (required with --yes)
|
|
19
|
-
--primary <key> the
|
|
19
|
+
--primary <key> the main template (default: the first)
|
|
20
20
|
--categories <keys> business categories (default: the templates')
|
|
21
21
|
--tags <tags> 1–6 tags for the look (required with --yes)
|
|
22
22
|
--pages <list|none> extra pages: contact, faq (default: both)
|
|
@@ -32,7 +32,9 @@ The starter is pinned to the tag matching this package's version. Everything is
|
|
|
32
32
|
|
|
33
33
|
## What you get
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
A theme is the look, a template is a business it is dressed as, and a design is one demo store of a template. Each business you pick becomes a template with one design. The main template's (`--primary`) is `theme/demo.json`; each other template's is `theme/demos/<key>.json`. `theme/theme.config.ts` declares every design with its `template` key, the business picked, so a template is never inferred from a design id. To give a template a second design later, add its demo file and declare `{ id, template, design_label, description }`; a template with two or more designs names each one by its own `design_label`.
|
|
36
|
+
|
|
37
|
+
Right after `create`, `npm run check` rejects exactly your to-do list. For a one-template theme that is four rules: `theme/placeholder-content` (the starter's placeholder products and photos, and the theme's placeholder description), `theme/structure` and `theme/template-screenshot` (each design's screenshot), and `theme/template-description` (each design's description). With two or more templates, `theme/template-versions` is added: each design must have its own home page.
|
|
36
38
|
|
|
37
39
|
The target folder must be missing, empty, or hold only `.git`. The `--force` flag allows writing into another folder but refuses file-or-folder clashes and symlinks at paths the starter writes. A regular file at the target path is always refused.
|
|
38
40
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { renameTheme, SKELETON, type Identity } from './rename.js';
|
|
|
8
8
|
/** The starter this release was tested with: its tag matches this package's version (`yarn starter:publish --tag`). */
|
|
9
9
|
export declare const STARTER: string;
|
|
10
10
|
export declare function detectPackageManager(userAgent?: string): PackageManager;
|
|
11
|
-
export declare const HELP = "Create a Queek storefront theme.\n\n npm create @usequeek/theme@latest my-theme -- --templates laundry --tags minimal\n pnpm create @usequeek/theme my-theme --templates laundry --tags minimal\n\nnpm needs -- before these flags. In a terminal, anything you leave out is asked,\nand with no folder the folder is named after the theme (my-theme with --yes or no terminal).\n\n --name <text> theme name (default: the folder name)\n --templates <keys> businesses to make templates for, comma-separated (required with --yes)\n --primary <key> the
|
|
11
|
+
export declare const HELP = "Create a Queek storefront theme.\n\n npm create @usequeek/theme@latest my-theme -- --templates laundry --tags minimal\n pnpm create @usequeek/theme my-theme --templates laundry --tags minimal\n\nnpm needs -- before these flags. In a terminal, anything you leave out is asked,\nand with no folder the folder is named after the theme (my-theme with --yes or no terminal).\n\n --name <text> theme name (default: the folder name)\n --templates <keys> businesses to make templates for, comma-separated (required with --yes)\n --primary <key> the main template (default: the first)\n --categories <keys> business categories (default: the templates')\n --tags <tags> 1\u20136 tags for the look (required with --yes)\n --pages <list|none> extra pages: contact, faq (default: both)\n --ai <list>, --no-ai AI assistants: claude, gemini (default: both; AGENTS.md unless --no-ai)\n --pm <npm|pnpm|yarn|bun>, --no-install, --no-git\n --yes, -y never prompt; take the default for everything else\n --dry-run print what would be written; write nothing\n --force allow a folder that is not empty\n --template <source> another starter: a giget source or a local folder";
|
|
12
12
|
export declare function createTheme(dir: string, answers: Answers, options: {
|
|
13
13
|
install: boolean;
|
|
14
14
|
git: boolean;
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ and with no folder the folder is named after the theme (my-theme with --yes or n
|
|
|
27
27
|
|
|
28
28
|
--name <text> theme name (default: the folder name)
|
|
29
29
|
--templates <keys> businesses to make templates for, comma-separated (required with --yes)
|
|
30
|
-
--primary <key> the
|
|
30
|
+
--primary <key> the main template (default: the first)
|
|
31
31
|
--categories <keys> business categories (default: the templates')
|
|
32
32
|
--tags <tags> 1–6 tags for the look (required with --yes)
|
|
33
33
|
--pages <list|none> extra pages: contact, faq (default: both)
|
package/dist/naming.d.ts
CHANGED
|
@@ -5,17 +5,25 @@ export declare function slugProblem(slug: string): string | null;
|
|
|
5
5
|
/** The CSS class prefix: the slug's initials, 2–4 characters, never a Queek theme's own. */
|
|
6
6
|
export declare function prefixFor(slug: string): string;
|
|
7
7
|
export interface TemplatePlan {
|
|
8
|
+
/** The design id: `default` (demo.json) for the main template, else the key (demos/<key>.json). */
|
|
8
9
|
id: string;
|
|
10
|
+
/** The business picked. */
|
|
9
11
|
key: string;
|
|
12
|
+
/** The template key theme.config.ts declares on the design (contract R2.8): the business picked. */
|
|
13
|
+
template: string;
|
|
10
14
|
label: string;
|
|
11
15
|
for: string[];
|
|
16
|
+
/** The main template, whose first design is demo.json. */
|
|
12
17
|
primary: boolean;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
|
-
* One
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* One template per business picked, each with one design (contract R2.8:
|
|
21
|
+
* theme → template → design). The main template's design is `default`
|
|
22
|
+
* (demo.json); every other design's id is its template's key, which makes it
|
|
23
|
+
* that template's design 1. The key is the business picked, so a template is
|
|
24
|
+
* never inferred from an id. A business category makes a general template, a
|
|
25
|
+
* niche a niche one — either way `for` is just that key, so a niche never
|
|
26
|
+
* names a category (R2.7).
|
|
19
27
|
*/
|
|
20
28
|
export declare function planTemplates(keys: string[], primary?: string): TemplatePlan[];
|
|
21
29
|
/** The business categories the templates belong to, once each, in order. */
|
package/dist/naming.js
CHANGED
|
@@ -27,10 +27,13 @@ export function prefixFor(slug) {
|
|
|
27
27
|
return candidates.find((prefix) => /^[a-z][a-z0-9]{1,3}$/.test(prefix) && !RESERVED_PREFIXES.includes(prefix) && prefix !== 'core') ?? `${slug[0]}q`;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* One
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* One template per business picked, each with one design (contract R2.8:
|
|
31
|
+
* theme → template → design). The main template's design is `default`
|
|
32
|
+
* (demo.json); every other design's id is its template's key, which makes it
|
|
33
|
+
* that template's design 1. The key is the business picked, so a template is
|
|
34
|
+
* never inferred from an id. A business category makes a general template, a
|
|
35
|
+
* niche a niche one — either way `for` is just that key, so a niche never
|
|
36
|
+
* names a category (R2.7).
|
|
34
37
|
*/
|
|
35
38
|
export function planTemplates(keys, primary) {
|
|
36
39
|
const unique = [...new Set(keys)];
|
|
@@ -38,7 +41,7 @@ export function planTemplates(keys, primary) {
|
|
|
38
41
|
return [];
|
|
39
42
|
const first = primary && unique.includes(primary) ? primary : unique[0];
|
|
40
43
|
const ordered = [first, ...unique.filter((key) => key !== first)];
|
|
41
|
-
return ordered.map((key, index) => ({ id: index === 0 ? 'default' : key, key, label: labelOf(key), for: [key], primary: index === 0 }));
|
|
44
|
+
return ordered.map((key, index) => ({ id: index === 0 ? 'default' : key, key, template: key, label: labelOf(key), for: [key], primary: index === 0 }));
|
|
42
45
|
}
|
|
43
46
|
/** The business categories the templates belong to, once each, in order. */
|
|
44
47
|
export function defaultCategories(keys) {
|
package/dist/prompts.js
CHANGED
|
@@ -41,7 +41,7 @@ export function clackPrompter() {
|
|
|
41
41
|
return answer(await p.autocompleteMultiselect({ message: 'Businesses to make templates for (type to search)', options: templateOptions(), required: true }));
|
|
42
42
|
},
|
|
43
43
|
async primary(keys) {
|
|
44
|
-
return answer(await p.select({ message: 'Which is the
|
|
44
|
+
return answer(await p.select({ message: 'Which template is the main one (the theme\'s first impression)?', options: keys.map(businessOption) }));
|
|
45
45
|
},
|
|
46
46
|
async categories(initial) {
|
|
47
47
|
return answer(await p.multiselect({ message: 'Business categories the theme serves', options: SERVICES.map((key) => ({ value: key, label: labelOf(key) })), initialValues: initial, required: true }));
|
package/dist/rename.d.ts
CHANGED
|
@@ -8,15 +8,21 @@ export declare const SKELETON: Identity;
|
|
|
8
8
|
/**
|
|
9
9
|
* Rename one file's identity as TOKENS: the root class (`theme-bare`), the demo
|
|
10
10
|
* ids (`demo-bare`, `demo-bare-home`), every class token (`bare-main
|
|
11
|
-
* bare-product` — both), the display name (`Bare`) and the slug (`bare`).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* bare-product` — both), the display name (`Bare`) and the slug (`bare`). A
|
|
12
|
+
* real theme adds more shapes of the same identity: CSS custom properties
|
|
13
|
+
* (`--md-accent`), data attributes (`data-md-open`), component heads
|
|
14
|
+
* (`MedleyModalLayer`), store ids (`medley-food`) and preview paths
|
|
15
|
+
* (`/medley~food`, via the slug token — `~` is a token edge). The skeleton
|
|
16
|
+
* keeps the English word "bare" out of its copy so every remaining standalone
|
|
17
|
+
* token is identity.
|
|
14
18
|
*
|
|
15
19
|
* The display name and the slug go in ONE pass (an alternation), so a name that
|
|
16
20
|
* holds the old slug as a word ("simply bare") is never rewritten by the slug
|
|
17
21
|
* pass. Nothing the earlier passes write can match it: the slug they write
|
|
18
22
|
* follows a `-` and a class prefix is followed by one, and a token has a `-` on
|
|
19
|
-
* neither side
|
|
23
|
+
* neither side — a store id (`<slug>-<id>`) keeps that shape, and a component
|
|
24
|
+
* head is only ever followed by an uppercase letter, which the token pass
|
|
25
|
+
* never spans.
|
|
20
26
|
*/
|
|
21
27
|
export declare function renameContent(content: string, ext: string, from: Identity, to: Identity): string;
|
|
22
28
|
/** Rename every text file of a theme folder in place. */
|
package/dist/rename.js
CHANGED
|
@@ -4,6 +4,20 @@ import { extname, join } from 'node:path';
|
|
|
4
4
|
export const SKELETON = { slug: 'bare', prefix: 'bare', name: 'Bare' };
|
|
5
5
|
const TEXT = new Set(['.ts', '.tsx', '.css', '.json', '.md', '.mdx']);
|
|
6
6
|
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
|
+
/**
|
|
8
|
+
* A URL (`https?://…` up to whitespace or a quote) names a hosted thing, not
|
|
9
|
+
* the copy: the source theme's art lives under its own folder until it is
|
|
10
|
+
* rehosted, so URLs stay out of every pass below.
|
|
11
|
+
*/
|
|
12
|
+
const URL = /(https?:\/\/[^\s'"`<>]*)/g;
|
|
13
|
+
/** `Sole Theory` → `SoleTheory`: the display name as the head of a component identifier. */
|
|
14
|
+
function pascalCase(name) {
|
|
15
|
+
return name
|
|
16
|
+
.split(/[^A-Za-z0-9]+/)
|
|
17
|
+
.filter((word) => word.length > 0)
|
|
18
|
+
.map((word) => word.slice(0, 1).toUpperCase() + word.slice(1))
|
|
19
|
+
.join('');
|
|
20
|
+
}
|
|
7
21
|
/** The display name as a literal of the file it is written into. */
|
|
8
22
|
function literal(ext, text) {
|
|
9
23
|
if (ext === '.json')
|
|
@@ -22,23 +36,54 @@ function literal(ext, text) {
|
|
|
22
36
|
/**
|
|
23
37
|
* Rename one file's identity as TOKENS: the root class (`theme-bare`), the demo
|
|
24
38
|
* ids (`demo-bare`, `demo-bare-home`), every class token (`bare-main
|
|
25
|
-
* bare-product` — both), the display name (`Bare`) and the slug (`bare`).
|
|
26
|
-
*
|
|
27
|
-
*
|
|
39
|
+
* bare-product` — both), the display name (`Bare`) and the slug (`bare`). A
|
|
40
|
+
* real theme adds more shapes of the same identity: CSS custom properties
|
|
41
|
+
* (`--md-accent`), data attributes (`data-md-open`), component heads
|
|
42
|
+
* (`MedleyModalLayer`), store ids (`medley-food`) and preview paths
|
|
43
|
+
* (`/medley~food`, via the slug token — `~` is a token edge). The skeleton
|
|
44
|
+
* keeps the English word "bare" out of its copy so every remaining standalone
|
|
45
|
+
* token is identity.
|
|
28
46
|
*
|
|
29
47
|
* The display name and the slug go in ONE pass (an alternation), so a name that
|
|
30
48
|
* holds the old slug as a word ("simply bare") is never rewritten by the slug
|
|
31
49
|
* pass. Nothing the earlier passes write can match it: the slug they write
|
|
32
50
|
* follows a `-` and a class prefix is followed by one, and a token has a `-` on
|
|
33
|
-
* neither side
|
|
51
|
+
* neither side — a store id (`<slug>-<id>`) keeps that shape, and a component
|
|
52
|
+
* head is only ever followed by an uppercase letter, which the token pass
|
|
53
|
+
* never spans.
|
|
34
54
|
*/
|
|
35
55
|
export function renameContent(content, ext, from, to) {
|
|
36
56
|
const nameOrSlug = new RegExp(`(?<![\\w-])(?:(${escape(from.name)})|${escape(from.slug)})(?![\\w-])`, 'g');
|
|
57
|
+
const rootClass = new RegExp(`(?<![\\w-])theme-${escape(from.slug)}(?![\\w-])`, 'g');
|
|
58
|
+
const demoId = new RegExp(`(?<![\\w-])demo-${escape(from.slug)}(?![\\w])`, 'g');
|
|
59
|
+
const storeId = new RegExp(`(?<![\\w-])${escape(from.slug)}-(?=[\\w$])`, 'g');
|
|
60
|
+
const cssVar = new RegExp(`--${escape(from.prefix)}-`, 'g');
|
|
61
|
+
const dataAttr = new RegExp(`data-${escape(from.prefix)}-`, 'g');
|
|
62
|
+
const classToken = new RegExp(`(?<![\\w-])${escape(from.prefix)}-(?=[\\w$])`, 'g');
|
|
63
|
+
const fromPascal = pascalCase(from.name);
|
|
64
|
+
const toPascal = pascalCase(to.name);
|
|
65
|
+
const componentHead = fromPascal.length > 0 && toPascal.length > 0 && fromPascal !== toPascal
|
|
66
|
+
? new RegExp(`(?<![\\w$])${escape(fromPascal)}(?=[A-Z])`, 'g')
|
|
67
|
+
: null;
|
|
68
|
+
const renameSegment = (segment) => {
|
|
69
|
+
let out = segment
|
|
70
|
+
.replace(rootClass, () => `theme-${to.slug}`)
|
|
71
|
+
.replace(demoId, () => `demo-${to.slug}`)
|
|
72
|
+
.replace(cssVar, () => `--${to.prefix}-`)
|
|
73
|
+
.replace(dataAttr, () => `data-${to.prefix}-`)
|
|
74
|
+
// The class prefix keeps its old priority: where slug and prefix spell the
|
|
75
|
+
// same token (the skeleton's `bare-`), the prefix wins, as before.
|
|
76
|
+
.replace(classToken, () => `${to.prefix}-`)
|
|
77
|
+
.replace(storeId, () => `${to.slug}-`);
|
|
78
|
+
if (componentHead)
|
|
79
|
+
out = out.replace(componentHead, () => toPascal);
|
|
80
|
+
return out.replace(nameOrSlug, (_match, name) => (name !== undefined ? literal(ext, to.name) : to.slug));
|
|
81
|
+
};
|
|
82
|
+
// Odd indexes are the URLs themselves (split keeps the capture); they pass through verbatim.
|
|
37
83
|
return content
|
|
38
|
-
.
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.replace(nameOrSlug, (_match, name) => (name !== undefined ? literal(ext, to.name) : to.slug));
|
|
84
|
+
.split(URL)
|
|
85
|
+
.map((part, index) => (index % 2 === 1 ? part : renameSegment(part)))
|
|
86
|
+
.join('');
|
|
42
87
|
}
|
|
43
88
|
function walk(dir) {
|
|
44
89
|
return readdirSync(dir).flatMap((name) => {
|
package/dist/setup.js
CHANGED
|
@@ -18,7 +18,7 @@ const ts = (text) => {
|
|
|
18
18
|
const list = (items) => `[${items.map(ts).join(', ')}]`;
|
|
19
19
|
export function themeConfigSource(answers) {
|
|
20
20
|
const [primary, ...others] = answers.templates;
|
|
21
|
-
const demos = others.map((plan) => ` {\n id: ${ts(plan.id)}, label: ${ts(plan.label)}, for: ${list(plan.for)},\n description: ${ts(DESCRIPTION)},\n },`).join('\n');
|
|
21
|
+
const demos = others.map((plan) => ` {\n id: ${ts(plan.id)}, template: ${ts(plan.template)}, label: ${ts(plan.label)}, for: ${list(plan.for)},\n description: ${ts(DESCRIPTION)},\n },`).join('\n');
|
|
22
22
|
return `const config = {
|
|
23
23
|
name: ${ts(answers.name)},
|
|
24
24
|
slug: ${ts(answers.slug)},
|
|
@@ -28,10 +28,20 @@ export function themeConfigSource(answers) {
|
|
|
28
28
|
tags: ${list(answers.tags)},
|
|
29
29
|
categories: ${list(answers.categories)},
|
|
30
30
|
rank: 0,
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
31
|
+
// Theme → template → design (docs/THEME.md#templates). A template is a
|
|
32
|
+
// business the theme is dressed as; a design is one demo store of it.
|
|
33
|
+
// demo.json is the main template's first design; each demos/<id>.json here
|
|
34
|
+
// is the first design of another template, so its id is its key.
|
|
35
|
+
// \`template\` is that key: a slug for the business, never renamed once
|
|
36
|
+
// shipped. \`label\` and \`for\` are the template's. \`for\`: a whole business
|
|
37
|
+
// leads with its category, a niche names only its product keys
|
|
38
|
+
// (docs/business-vocabulary.json).
|
|
39
|
+
// To give a template a second design, add a demos/<id>.json with any unused
|
|
40
|
+
// id and declare it \`{ id, template, design_label, description }\`: it
|
|
41
|
+
// inherits the template's label and for. A template with two or more
|
|
42
|
+
// designs (three at most) names each one by its own \`design_label\`.
|
|
34
43
|
default_demo: {
|
|
44
|
+
template: ${ts(primary.template)},
|
|
35
45
|
label: ${ts(primary.label)},
|
|
36
46
|
for: ${list(primary.for)},
|
|
37
47
|
description: ${ts(DESCRIPTION)},
|