@usequeek/create-theme 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Queek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @usequeek/create-theme
2
+
3
+ Start a theme for [Queek](https://usequeek.com) storefronts from the official
4
+ [starter](https://github.com/usequeek/theme-starter).
5
+
6
+ ```bash
7
+ npm create @usequeek/theme my-theme
8
+ # or: pnpm create @usequeek/theme my-theme · yarn create @usequeek/theme my-theme
9
+ ```
10
+
11
+ It copies the starter into `my-theme`, names the package after the folder and installs
12
+ dependencies with the package manager you ran it with (`-- --no-install` to skip). Then:
13
+
14
+ ```bash
15
+ cd my-theme
16
+ npm run dev
17
+ ```
18
+
19
+ ## License
20
+
21
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * npm create @usequeek/theme [dir] [--no-install]
4
+ * (npm maps `npm create @usequeek/theme` to this package: @usequeek/create-theme.)
5
+ */
6
+ import { parseArgs } from 'node:util';
7
+ import { createTheme } from './index.js';
8
+ const { values, positionals } = parseArgs({
9
+ allowPositionals: true,
10
+ options: {
11
+ install: { type: 'boolean', default: true },
12
+ 'no-install': { type: 'boolean', default: false },
13
+ help: { type: 'boolean', short: 'h', default: false },
14
+ },
15
+ });
16
+ if (values.help) {
17
+ console.log('Usage: npm create @usequeek/theme [dir] [-- --no-install]\n\nCopies the Queek theme starter into dir (default: my-theme) and installs its dependencies.');
18
+ process.exit(0);
19
+ }
20
+ createTheme({ dir: positionals[0] ?? 'my-theme', install: values.install && !values['no-install'] }).catch((error) => {
21
+ console.error(`\n✖ ${error.message}`);
22
+ process.exit(1);
23
+ });
@@ -0,0 +1,18 @@
1
+ /** The official starter: theme files only, the tools come from npm. */
2
+ export declare const STARTER = "github:usequeek/theme-starter";
3
+ export interface CreateThemeOptions {
4
+ /** Folder to create. Must be empty or missing. */
5
+ dir: string;
6
+ /** Run the package manager's install afterwards. */
7
+ install?: boolean;
8
+ /** Where progress goes; stdout by default. */
9
+ log?: (line: string) => void;
10
+ /** giget source — overridable for tests and forks. */
11
+ template?: string;
12
+ }
13
+ type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
14
+ /** The package manager that ran us (`npm create`, `pnpm create`…), from the user agent it sets. */
15
+ export declare function detectPackageManager(userAgent?: string): PackageManager;
16
+ /** Copy the starter into `dir`, name the package after the folder, and install. */
17
+ export declare function createTheme(options: CreateThemeOptions): Promise<void>;
18
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { basename, join, relative, resolve } from 'node:path';
4
+ import { downloadTemplate } from 'giget';
5
+ /** The official starter: theme files only, the tools come from npm. */
6
+ export const STARTER = 'github:usequeek/theme-starter';
7
+ /** The package manager that ran us (`npm create`, `pnpm create`…), from the user agent it sets. */
8
+ export function detectPackageManager(userAgent = process.env.npm_config_user_agent ?? '') {
9
+ const name = userAgent.split('/')[0];
10
+ return name === 'pnpm' || name === 'yarn' || name === 'bun' ? name : 'npm';
11
+ }
12
+ /** Copy the starter into `dir`, name the package after the folder, and install. */
13
+ export async function createTheme(options) {
14
+ const log = options.log ?? ((line) => console.log(line));
15
+ const dir = resolve(options.dir);
16
+ if (existsSync(dir) && readdirSync(dir).length > 0) {
17
+ throw new Error(`${options.dir} already exists and is not empty. Choose a new folder.`);
18
+ }
19
+ log(`Creating a Queek theme in ${relative(process.cwd(), dir) || '.'}…`);
20
+ await downloadTemplate(options.template ?? STARTER, { dir, force: true });
21
+ const manifest = join(dir, 'package.json');
22
+ if (existsSync(manifest)) {
23
+ const pkg = JSON.parse(readFileSync(manifest, 'utf8'));
24
+ pkg.name = basename(dir).toLowerCase().replace(/[^a-z0-9-]+/g, '-');
25
+ writeFileSync(manifest, `${JSON.stringify(pkg, null, 2)}\n`);
26
+ }
27
+ const pm = detectPackageManager();
28
+ if (options.install !== false) {
29
+ log(`Installing dependencies with ${pm}…`);
30
+ const result = spawnSync(pm, ['install'], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
31
+ if (result.status !== 0)
32
+ throw new Error(`${pm} install failed. Run it yourself in ${options.dir}.`);
33
+ }
34
+ const run = pm === 'npm' ? 'npm run' : pm;
35
+ log('');
36
+ log('Done. Next:');
37
+ log(` cd ${relative(process.cwd(), dir) || '.'}`);
38
+ if (options.install === false)
39
+ log(` ${pm} install`);
40
+ log(` ${run} dev # preview every page at http://localhost:3000`);
41
+ log(` ${run} check # check it against the Queek theme contract`);
42
+ log('');
43
+ log('Build the theme in theme/. The contract is docs/THEME.md.');
44
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@usequeek/create-theme",
3
+ "version": "0.1.0",
4
+ "description": "npm create @usequeek/theme — start a Queek storefront theme from the official starter.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "create-theme": "./dist/cli.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "!dist/**/*.map"
19
+ ],
20
+ "engines": {
21
+ "node": ">=22.12.0"
22
+ },
23
+ "dependencies": {
24
+ "giget": "^3.3.1"
25
+ },
26
+ "keywords": [
27
+ "queek",
28
+ "theme",
29
+ "storefront",
30
+ "create",
31
+ "starter"
32
+ ],
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/usequeek/theme-tools.git",
36
+ "directory": "packages/create-theme"
37
+ },
38
+ "bugs": "https://github.com/usequeek/theme-tools/issues",
39
+ "homepage": "https://github.com/usequeek/theme-tools/tree/main/packages/create-theme#readme",
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "provenance": true
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -p tsconfig.build.json",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit"
47
+ }
48
+ }