@picloom/create-theme 0.0.0-stage → 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/index.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bun
2
+ import {
3
+ cp,
4
+ mkdir,
5
+ readFile,
6
+ readdir,
7
+ rename,
8
+ writeFile,
9
+ } from "node:fs/promises";
10
+ import { basename, resolve } from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+
13
+ const args = process.argv.slice(2);
14
+ if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
15
+ console.log("Usage: bun create @picloom/theme <new-directory>");
16
+ } else if (args.length !== 1 || args[0].startsWith("-")) {
17
+ console.error("Usage: bun create @picloom/theme <new-directory>");
18
+ process.exitCode = 1;
19
+ } else {
20
+ try {
21
+ const target = resolve(args[0]);
22
+ // Refuse even empty existing directories: never merge into a user's project.
23
+ await mkdir(target);
24
+ const template = fileURLToPath(
25
+ new URL("./dist/template/", import.meta.url),
26
+ );
27
+ for (const entry of await readdir(template)) {
28
+ await cp(resolve(template, entry), resolve(target, entry), {
29
+ recursive: true,
30
+ force: false,
31
+ errorOnExist: true,
32
+ });
33
+ }
34
+ // Package managers may rename/omit .gitignore when packing, so ship it under a plain name.
35
+ await rename(resolve(target, "gitignore"), resolve(target, ".gitignore"));
36
+ const name =
37
+ basename(target)
38
+ .toLowerCase()
39
+ .replace(/[^a-z0-9._-]/g, "-")
40
+ .replace(/^[^a-z]+/, "")
41
+ .slice(0, 80)
42
+ .replace(/\.+$/, "") || "my-theme";
43
+ const manifestPath = resolve(target, "theme.json");
44
+ const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
45
+ manifest.id = `example.${name}`;
46
+ await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
47
+ const packagePath = resolve(target, "package.json");
48
+ const pkg = JSON.parse(await readFile(packagePath, "utf8"));
49
+ pkg.name = name;
50
+ await writeFile(packagePath, JSON.stringify(pkg, null, 2) + "\n");
51
+ const quotedDirectory = "'" + args[0].replaceAll("'", "'\\''") + "'";
52
+ console.log(
53
+ `Created ${target}\n\nNext:\n cd ${quotedDirectory}\n bun install\n bun run dev\n bun run build\n\nUpload dist/${manifest.id}-${manifest.version}.zip to Picloom.`,
54
+ );
55
+ } catch (error) {
56
+ console.error(
57
+ error.code === "EEXIST"
58
+ ? "Target already exists. Choose a new directory; no existing files were changed."
59
+ : `Could not create theme: ${error.message}`,
60
+ );
61
+ process.exitCode = 1;
62
+ }
63
+ }
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@picloom/create-theme",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Create a standalone Picloom Vue theme with local preview and ZIP packaging",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "create-theme": "./index.js"
9
+ },
10
+ "engines": {
11
+ "bun": ">=1.4.3"
12
+ },
13
+ "scripts": {
14
+ "build": "bun prepare.ts",
15
+ "prepack": "bun run build"
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "dist/template",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/llleixx/picloom.git",
26
+ "directory": "tools/create-theme"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }