@usequeek/create-theme 0.9.0 → 0.10.0

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/dist/index.d.ts CHANGED
@@ -2,7 +2,10 @@ import { type Flags, type PackageManager, type Prompter } from './options.js';
2
2
  import { type Answers } from './setup.js';
3
3
  export { UsageError, CancelledError, type Flags, type Prompter, type PackageManager } from './options.js';
4
4
  export { setupTheme, type Answers } from './setup.js';
5
- export { clackPrompter } from './prompts.js';
5
+ export { buildDemoStore, optionalPagesOf, TEMPLATE_DESCRIPTION, type OptionalPage, type SkeletonStore } from './setup.js';
6
+ export { appendDemoEntry, setDesignLabel } from './config-edit.js';
7
+ export { planAddTemplate, planAddDesign, planAddPage, applyAddPlan, vocabularyLists, type AddPlan } from './add.js';
8
+ export { clackPrompter, templateOptions } from './prompts.js';
6
9
  export { bundledLists, cachedLists, createLists, getActiveLists, setActiveLists, SHOP_HINT, SHOP_KEY, SHOP_LABEL, type BusinessLists, type BusinessOption, type ListsData } from './lists.js';
7
10
  /** The rename `npm create` applies to the starter, for tools that copy a theme under a new name (Queek's `yarn theme:new`). */
8
11
  export { renameTheme, SKELETON, type Identity } from './rename.js';
package/dist/index.js CHANGED
@@ -9,7 +9,10 @@ import { UsageError, equivalentCommand, resolveAnswers, shellWord } from './opti
9
9
  import { setupTheme } from './setup.js';
10
10
  export { UsageError, CancelledError } from './options.js';
11
11
  export { setupTheme } from './setup.js';
12
- export { clackPrompter } from './prompts.js';
12
+ export { buildDemoStore, optionalPagesOf, TEMPLATE_DESCRIPTION } from './setup.js';
13
+ export { appendDemoEntry, setDesignLabel } from './config-edit.js';
14
+ export { planAddTemplate, planAddDesign, planAddPage, applyAddPlan, vocabularyLists } from './add.js';
15
+ export { clackPrompter, templateOptions } from './prompts.js';
13
16
  export { bundledLists, cachedLists, createLists, getActiveLists, setActiveLists, SHOP_HINT, SHOP_KEY, SHOP_LABEL } from './lists.js';
14
17
  /** The rename `npm create` applies to the starter, for tools that copy a theme under a new name (Queek's `yarn theme:new`). */
15
18
  export { renameTheme, SKELETON } from './rename.js';
@@ -212,6 +215,7 @@ export async function createTheme(dir, answers, options) {
212
215
  log(` ${options.pm} install`);
213
216
  log(` ${run} dev # preview every template`);
214
217
  log(` ${run} check # your to-do list: each template's description, its own home and screenshot, your products and photos`);
218
+ log('Guides: https://docs.usequeek.com/docs/themes');
215
219
  log('');
216
220
  log(`To repeat this setup: ${equivalentCommand(options.pm, dir, answers, { template: options.template, install: options.install, git: options.git, offline: options.offline, vocabularyFile: options.vocabularyFile })}`);
217
221
  }
package/dist/setup.d.ts CHANGED
@@ -11,6 +11,45 @@ export interface Answers {
11
11
  pages: OptionalPage[];
12
12
  ai: Assistant[] | false;
13
13
  }
14
+ /**
15
+ * Every new template's description, whatever command writes it. It starts
16
+ * with the text the check rejects, so no template ships with it — `queek
17
+ * theme check` then lists it as the author's to-do.
18
+ */
19
+ export declare const TEMPLATE_DESCRIPTION = "Replace before publishing. Who this template fits, the look, its signature sections and the photos it needs, in at most 300 characters.";
14
20
  export declare function themeConfigSource(answers: Answers): string;
21
+ export type MenuItem = {
22
+ type?: string;
23
+ label?: string;
24
+ ref?: string;
25
+ children?: MenuItem[];
26
+ };
27
+ export type Menu = {
28
+ id?: string;
29
+ location?: string;
30
+ items?: MenuItem[];
31
+ };
32
+ /** A demo store file, as parsed: only the fields the builders touch are typed. */
33
+ export interface SkeletonStore {
34
+ profile?: Record<string, unknown>;
35
+ products?: Array<Record<string, unknown>>;
36
+ pages?: Record<string, Record<string, unknown>>;
37
+ menus?: Menu[];
38
+ [key: string]: unknown;
39
+ }
40
+ /**
41
+ * One demo store from the skeleton's: fresh shop ids, only the wanted pages,
42
+ * and menus pointing at those pages. `slug` is the slug the skeleton already
43
+ * carries (create renames it before this runs); `shopId` is the new store's
44
+ * profile id. `queek theme add template` builds through this too, so a store
45
+ * added later is the same shape as one `create` wrote.
46
+ */
47
+ export declare function buildDemoStore(skeleton: SkeletonStore, opts: {
48
+ slug: string;
49
+ shopId: string;
50
+ pages: OptionalPage[];
51
+ }): SkeletonStore;
52
+ /** The optional pages a store carries — what `add template` copies the theme's page choice from. */
53
+ export declare function optionalPagesOf(store: Pick<SkeletonStore, 'pages'>): OptionalPage[];
15
54
  /** Turn a downloaded starter into the developer's theme. Pure file work: no network, no install. */
16
55
  export declare function setupTheme(projectDir: string, answers: Answers): void;
package/dist/setup.js CHANGED
@@ -3,8 +3,13 @@ import { join } from 'node:path';
3
3
  import { SKELETON, renameTheme } from './rename.js';
4
4
  /** Written for every template, whatever the developer picks. */
5
5
  const REQUIRED_PAGES = ['home', 'shop', 'about', 'sales', 'landing'];
6
- /** Must start with the text the check rejects, so no template ships with it. */
7
- const DESCRIPTION = 'Replace before publishing. Who this template fits, the look, its signature sections and the photos it needs, in at most 300 characters.';
6
+ /**
7
+ * Every new template's description, whatever command writes it. It starts
8
+ * with the text the check rejects, so no template ships with it — `queek
9
+ * theme check` then lists it as the author's to-do.
10
+ */
11
+ export const TEMPLATE_DESCRIPTION = 'Replace before publishing. Who this template fits, the look, its signature sections and the photos it needs, in at most 300 characters.';
12
+ const DESCRIPTION = TEMPLATE_DESCRIPTION;
8
13
  const ts = (text) => {
9
14
  const escaped = text
10
15
  .replace(/\\/g, '\\\\')
@@ -59,22 +64,38 @@ function dropMissingPages(items, pages) {
59
64
  ?.filter((item) => item.type !== 'page' || (typeof item.ref === 'string' && pages.has(item.ref)))
60
65
  .map((item) => ({ ...item, ...(item.children ? { children: dropMissingPages(item.children, pages) } : {}) }));
61
66
  }
67
+ /**
68
+ * One demo store from the skeleton's: fresh shop ids, only the wanted pages,
69
+ * and menus pointing at those pages. `slug` is the slug the skeleton already
70
+ * carries (create renames it before this runs); `shopId` is the new store's
71
+ * profile id. `queek theme add template` builds through this too, so a store
72
+ * added later is the same shape as one `create` wrote.
73
+ */
74
+ export function buildDemoStore(skeleton, opts) {
75
+ const store = structuredClone(skeleton);
76
+ const keep = new Set([...REQUIRED_PAGES, ...opts.pages]);
77
+ store.profile = { ...store.profile, id: opts.shopId };
78
+ for (const product of store.products ?? []) {
79
+ product.shop_id = opts.shopId;
80
+ if (product.shop && typeof product.shop === 'object')
81
+ product.shop = { ...product.shop, id: opts.shopId };
82
+ }
83
+ store.pages = Object.fromEntries(Object.entries(store.pages ?? {})
84
+ .filter(([slug]) => keep.has(slug))
85
+ .map(([slug, page]) => [slug, { ...page, ...(typeof page.id === 'string' ? { id: page.id.replace(`demo-${opts.slug}`, opts.shopId) } : {}) }]));
86
+ store.menus = store.menus?.map((menu) => ({ ...menu, items: dropMissingPages(menu.items, keep) }));
87
+ return store;
88
+ }
89
+ /** The optional pages a store carries — what `add template` copies the theme's page choice from. */
90
+ export function optionalPagesOf(store) {
91
+ const pages = store.pages ?? {};
92
+ return ['contact', 'faq'].filter((page) => page in pages);
93
+ }
62
94
  function writeDemoStores(themeDir, answers) {
63
95
  const skeleton = JSON.parse(readFileSync(join(themeDir, 'demo.json'), 'utf8'));
64
- const keep = new Set([...REQUIRED_PAGES, ...answers.pages]);
65
96
  for (const plan of answers.templates) {
66
- const store = structuredClone(skeleton);
67
97
  const shopId = plan.primary ? `demo-${answers.slug}` : `demo-${answers.slug}-${plan.id}`;
68
- store.profile = { ...store.profile, id: shopId };
69
- for (const product of store.products ?? []) {
70
- product.shop_id = shopId;
71
- if (product.shop)
72
- product.shop = { ...product.shop, id: shopId };
73
- }
74
- store.pages = Object.fromEntries(Object.entries(store.pages)
75
- .filter(([slug]) => keep.has(slug))
76
- .map(([slug, page]) => [slug, { ...page, ...(typeof page.id === 'string' ? { id: page.id.replace(`demo-${answers.slug}`, shopId) } : {}) }]));
77
- store.menus = store.menus?.map((menu) => ({ ...menu, items: dropMissingPages(menu.items, keep) }));
98
+ const store = buildDemoStore(skeleton, { slug: answers.slug, shopId, pages: answers.pages });
78
99
  const path = plan.primary ? join(themeDir, 'demo.json') : join(themeDir, 'demos', `${plan.id}.json`);
79
100
  mkdirSync(join(themeDir, 'demos'), { recursive: true });
80
101
  writeFileSync(path, `${JSON.stringify(store, null, 2)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/create-theme",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "npm create @usequeek/theme — start a Queek storefront theme from the official starter.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,8 +22,9 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@clack/prompts": "^1.8.1",
25
- "@usequeek/theme-check": "^0.9.0",
26
- "giget": "^3.3.1"
25
+ "@usequeek/theme-check": "^0.9.1",
26
+ "giget": "^3.3.1",
27
+ "magicast": "^0.5.5"
27
28
  },
28
29
  "keywords": [
29
30
  "queek",