create-mud 2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30 → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2

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/cli.cjs ADDED
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // ../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.17.16__jiti@1.21.6_postcss@8.5.1_ts_rihtmhm6tp3cagz6w7ivhbdyn4/node_modules/tsup/assets/cjs_shims.js
26
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
27
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
28
+
29
+ // src/bin/cli.ts
30
+ var import_promises2 = __toESM(require("fs/promises"), 1);
31
+ var import_node_path = __toESM(require("path"), 1);
32
+ var import_node_url = require("url");
33
+ var import_yargs_interactive = __toESM(require("yargs-interactive"), 1);
34
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
35
+
36
+ // package.json
37
+ var package_default = {
38
+ name: "create-mud",
39
+ version: "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
40
+ description: "Create a new MUD project",
41
+ license: "MIT",
42
+ author: "Lattice <mud@lattice.xyz>",
43
+ type: "module",
44
+ bin: "bin/cli.js",
45
+ files: [
46
+ "bin",
47
+ "dist",
48
+ "templates"
49
+ ],
50
+ scripts: {
51
+ build: "pnpm run build:js",
52
+ "build:js": "tsup && pnpm run copy-templates",
53
+ clean: "pnpm run clean:js",
54
+ "clean:js": "shx rm -rf dist",
55
+ "copy-templates": "tsx ./scripts/copy-templates.ts",
56
+ dev: "tsup --watch",
57
+ prepublishOnly: "npm run clean && npm run build",
58
+ test: "shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs",
59
+ "test:ci": "pnpm run test",
60
+ "test:phaser": "bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project",
61
+ "test:react": "bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project",
62
+ "test:react-ecs": "bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project",
63
+ "test:threejs": "bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project",
64
+ "test:vanilla": "bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project"
65
+ },
66
+ dependencies: {
67
+ "fast-glob": "^3.3.3",
68
+ "yargs-interactive": "^3.0.1"
69
+ },
70
+ devDependencies: {
71
+ "@types/yargs-interactive": "^2.1.6"
72
+ },
73
+ publishConfig: {
74
+ access: "public",
75
+ registry: "https://registry.npmjs.org"
76
+ }
77
+ };
78
+
79
+ // src/common.ts
80
+ var templates = ["react", "react-ecs", "phaser", "threejs", "vanilla"];
81
+
82
+ // src/exists.ts
83
+ var import_promises = __toESM(require("fs/promises"), 1);
84
+ async function exists(path2) {
85
+ try {
86
+ await import_promises.default.access(path2);
87
+ return true;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }
92
+
93
+ // src/bin/cli.ts
94
+ var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
95
+ var __dirname = import_node_path.default.dirname(__filename2);
96
+ async function run() {
97
+ (0, import_yargs_interactive.default)().usage("$0 [args]").interactive({
98
+ interactive: { default: true },
99
+ name: {
100
+ describe: "Name your project",
101
+ type: "input"
102
+ },
103
+ template: {
104
+ describe: "Pick a template",
105
+ type: "list",
106
+ choices: templates
107
+ },
108
+ "mud-version": {
109
+ type: "input",
110
+ describe: "The version of MUD packages to use, defaults to latest",
111
+ default: package_default.version
112
+ }
113
+ }).then(async (args) => {
114
+ if (!args.name) throw new Error("No project name provided.");
115
+ const destDir = import_node_path.default.join(process.cwd(), args.name);
116
+ if (await exists(destDir)) {
117
+ throw new Error(`Target directory "${destDir}" already exists.`);
118
+ }
119
+ const sourceDir = import_node_path.default.join(__dirname, "..", "templates", args.template);
120
+ const files = await (0, import_fast_glob.default)("**/*", { cwd: sourceDir, dot: true });
121
+ for (const filename of files) {
122
+ const sourceFile = import_node_path.default.join(sourceDir, filename);
123
+ const destFile = import_node_path.default.join(destDir, filename);
124
+ await import_promises2.default.mkdir(import_node_path.default.dirname(destFile), { recursive: true });
125
+ if (/package\.json$/.test(sourceFile)) {
126
+ const source = await import_promises2.default.readFile(sourceFile, "utf-8");
127
+ await import_promises2.default.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), "utf-8");
128
+ } else if (/\.gitignore_$/.test(sourceFile)) {
129
+ await import_promises2.default.copyFile(sourceFile, destFile.replace(/_$/, ""));
130
+ } else {
131
+ await import_promises2.default.copyFile(sourceFile, destFile);
132
+ }
133
+ }
134
+ console.log(`
135
+ New project created! Run it with:
136
+
137
+ cd ${args.name}
138
+ pnpm install
139
+ pnpm dev
140
+
141
+ Have fun! For more info, check the docs at https://mud.dev/
142
+ `);
143
+ });
144
+ }
145
+ run();
146
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.17.16__jiti@1.21.6_postcss@8.5.1_ts_rihtmhm6tp3cagz6w7ivhbdyn4/node_modules/tsup/assets/cjs_shims.js","../src/bin/cli.ts","../package.json","../src/common.ts","../src/exists.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport yargsInteractive from \"yargs-interactive\";\nimport glob from \"fast-glob\";\nimport packageJson from \"../../package.json\";\nimport { templates } from \"../common\";\nimport { exists } from \"../exists\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nasync function run() {\n yargsInteractive()\n .usage(\"$0 [args]\")\n .interactive({\n interactive: { default: true },\n name: {\n describe: \"Name your project\",\n type: \"input\",\n },\n template: {\n describe: \"Pick a template\",\n type: \"list\",\n choices: templates,\n },\n \"mud-version\": {\n type: \"input\",\n describe: \"The version of MUD packages to use, defaults to latest\",\n default: packageJson.version,\n },\n })\n .then(async (args) => {\n if (!args.name) throw new Error(\"No project name provided.\");\n\n const destDir = path.join(process.cwd(), args.name);\n if (await exists(destDir)) {\n throw new Error(`Target directory \"${destDir}\" already exists.`);\n }\n\n const sourceDir = path.join(__dirname, \"..\", \"templates\", args.template);\n const files = await glob(\"**/*\", { cwd: sourceDir, dot: true });\n\n for (const filename of files) {\n const sourceFile = path.join(sourceDir, filename);\n const destFile = path.join(destDir, filename);\n\n await fs.mkdir(path.dirname(destFile), { recursive: true });\n\n if (/package\\.json$/.test(sourceFile)) {\n const source = await fs.readFile(sourceFile, \"utf-8\");\n await fs.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), \"utf-8\");\n } else if (/\\.gitignore_$/.test(sourceFile)) {\n await fs.copyFile(sourceFile, destFile.replace(/_$/, \"\"));\n } else {\n await fs.copyFile(sourceFile, destFile);\n }\n }\n\n console.log(`\nNew project created! Run it with:\n\n cd ${args.name}\n pnpm install\n pnpm dev\n\nHave fun! For more info, check the docs at https://mud.dev/\n`);\n });\n}\n\nrun();\n","{\n \"name\": \"create-mud\",\n \"version\": \"2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2\",\n \"description\": \"Create a new MUD project\",\n \"license\": \"MIT\",\n \"author\": \"Lattice <mud@lattice.xyz>\",\n \"type\": \"module\",\n \"bin\": \"bin/cli.js\",\n \"files\": [\n \"bin\",\n \"dist\",\n \"templates\"\n ],\n \"scripts\": {\n \"build\": \"pnpm run build:js\",\n \"build:js\": \"tsup && pnpm run copy-templates\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"shx rm -rf dist\",\n \"copy-templates\": \"tsx ./scripts/copy-templates.ts\",\n \"dev\": \"tsup --watch\",\n \"prepublishOnly\": \"npm run clean && npm run build\",\n \"test\": \"shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs\",\n \"test:ci\": \"pnpm run test\",\n \"test:phaser\": \"bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react\": \"bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react-ecs\": \"bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:threejs\": \"bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:vanilla\": \"bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project\"\n },\n \"dependencies\": {\n \"fast-glob\": \"^3.3.3\",\n \"yargs-interactive\": \"^3.0.1\"\n },\n \"devDependencies\": {\n \"@types/yargs-interactive\": \"^2.1.6\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org\"\n }\n}\n","// We define these here to keep them in the order we want to present in the CLI.\n// Tests will ensure this list stays up to date.\nexport const templates = [\"react\", \"react-ecs\", \"phaser\", \"threejs\", \"vanilla\"];\n","import fs from \"node:fs/promises\";\n\nexport async function exists(path: string) {\n try {\n await fs.access(path);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;;;ACX9D,IAAAA,mBAAe;AACf,uBAAiB;AACjB,sBAA8B;AAC9B,+BAA6B;AAC7B,uBAAiB;;;ACJjB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,MAAQ;AAAA,EACR,KAAO;AAAA,EACP,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,YAAY;AAAA,IACZ,OAAS;AAAA,IACT,YAAY;AAAA,IACZ,kBA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AO,mBAAmB;AAAA,IACjE;AAEA,UAAM,YAAY,iBAAAA,QAAK,KAAK,WAAW,MAAM,aAAa,KAAK,QAAQ;AACvE,UAAM,QAAQ,UAAM,iBAAAE,SAAK,QAAQ,EAAE,KAAK,WAAW,KAAK,KAAK,CAAC;AAE9D,eAAW,YAAY,OAAO;AAC5B,YAAM,aAAa,iBAAAF,QAAK,KAAK,WAAW,QAAQ;AAChD,YAAM,WAAW,iBAAAA,QAAK,KAAK,SAAS,QAAQ;AAE5C,YAAM,iBAAAG,QAAG,MAAM,iBAAAH,QAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAE1D,UAAI,iBAAiB,KAAK,UAAU,GAAG;AACrC,cAAM,SAAS,MAAM,iBAAAG,QAAG,SAAS,YAAY,OAAO;AACpD,cAAM,iBAAAA,QAAG,UAAU,UAAU,OAAO,WAAW,oBAAoB,KAAK,UAAU,GAAG,OAAO;AAAA,MAC9F,WAAW,gBAAgB,KAAK,UAAU,GAAG;AAC3C,cAAM,iBAAAA,QAAG,SAAS,YAAY,SAAS,QAAQ,MAAM,EAAE,CAAC;AAAA,MAC1D,OAAO;AACL,cAAM,iBAAAA,QAAG,SAAS,YAAY,QAAQ;AAAA,MACxC;AAAA,IACF;AAEA,YAAQ,IAAI;AAAA;AAAA;AAAA,OAGX,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,CAKf;AAAA,EACG,CAAC;AACL;AAEA,IAAI;","names":["import_promises","path","fs","__filename","path","yargsInteractive","glob","fs"]}
package/dist/cli.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js CHANGED
@@ -1,10 +1,118 @@
1
- import s from"node:fs/promises";import t from"node:path";import{fileURLToPath as j}from"node:url";import h from"yargs-interactive";import y from"fast-glob";var c={name:"create-mud",version:"2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30",description:"Create a new MUD project",license:"MIT",author:"Lattice <mud@lattice.xyz>",type:"module",bin:"bin/cli.js",files:["bin","dist","templates"],scripts:{build:"pnpm run build:js","build:js":"tsup && pnpm run copy-templates",clean:"pnpm run clean:js","clean:js":"shx rm -rf dist","copy-templates":"tsx ./scripts/copy-templates.ts",dev:"tsup --watch",prepublishOnly:"npm run clean && npm run build",test:"shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs","test:ci":"pnpm run test","test:phaser":"bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project","test:react":"bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project","test:react-ecs":"bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project","test:threejs":"bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project","test:vanilla":"bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project"},dependencies:{"fast-glob":"^3.3.3","yargs-interactive":"^3.0.1"},devDependencies:{"@types/yargs-interactive":"^2.1.6"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"}};var o=["react","react-ecs","phaser","threejs","vanilla"];import f from"node:fs/promises";async function m(e){try{return await f.access(e),!0}catch{return!1}}var v=j(import.meta.url),b=t.dirname(v);async function w(){h().usage("$0 [args]").interactive({interactive:{default:!0},name:{describe:"Name your project",type:"input"},template:{describe:"Pick a template",type:"list",choices:o},"mud-version":{type:"input",describe:"The version of MUD packages to use, defaults to latest",default:c.version}}).then(async e=>{if(!e.name)throw new Error("No project name provided.");let n=t.join(process.cwd(),e.name);if(await m(n))throw new Error(`Target directory "${n}" already exists.`);let p=t.join(b,"..","templates",e.template),l=await y("**/*",{cwd:p,dot:!0});for(let a of l){let r=t.join(p,a),i=t.join(n,a);if(await s.mkdir(t.dirname(i),{recursive:!0}),/package\.json$/.test(r)){let u=await s.readFile(r,"utf-8");await s.writeFile(i,u.replaceAll(/{{mud-version}}/g,e.mudVersion),"utf-8")}else/\.gitignore_$/.test(r)?await s.copyFile(r,i.replace(/_$/,"")):await s.copyFile(r,i)}console.log(`
1
+ // src/bin/cli.ts
2
+ import fs2 from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import yargsInteractive from "yargs-interactive";
6
+ import glob from "fast-glob";
7
+
8
+ // package.json
9
+ var package_default = {
10
+ name: "create-mud",
11
+ version: "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
12
+ description: "Create a new MUD project",
13
+ license: "MIT",
14
+ author: "Lattice <mud@lattice.xyz>",
15
+ type: "module",
16
+ bin: "bin/cli.js",
17
+ files: [
18
+ "bin",
19
+ "dist",
20
+ "templates"
21
+ ],
22
+ scripts: {
23
+ build: "pnpm run build:js",
24
+ "build:js": "tsup && pnpm run copy-templates",
25
+ clean: "pnpm run clean:js",
26
+ "clean:js": "shx rm -rf dist",
27
+ "copy-templates": "tsx ./scripts/copy-templates.ts",
28
+ dev: "tsup --watch",
29
+ prepublishOnly: "npm run clean && npm run build",
30
+ test: "shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs",
31
+ "test:ci": "pnpm run test",
32
+ "test:phaser": "bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project",
33
+ "test:react": "bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project",
34
+ "test:react-ecs": "bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project",
35
+ "test:threejs": "bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project",
36
+ "test:vanilla": "bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project"
37
+ },
38
+ dependencies: {
39
+ "fast-glob": "^3.3.3",
40
+ "yargs-interactive": "^3.0.1"
41
+ },
42
+ devDependencies: {
43
+ "@types/yargs-interactive": "^2.1.6"
44
+ },
45
+ publishConfig: {
46
+ access: "public",
47
+ registry: "https://registry.npmjs.org"
48
+ }
49
+ };
50
+
51
+ // src/common.ts
52
+ var templates = ["react", "react-ecs", "phaser", "threejs", "vanilla"];
53
+
54
+ // src/exists.ts
55
+ import fs from "node:fs/promises";
56
+ async function exists(path2) {
57
+ try {
58
+ await fs.access(path2);
59
+ return true;
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ // src/bin/cli.ts
66
+ var __filename2 = fileURLToPath(import.meta.url);
67
+ var __dirname2 = path.dirname(__filename2);
68
+ async function run() {
69
+ yargsInteractive().usage("$0 [args]").interactive({
70
+ interactive: { default: true },
71
+ name: {
72
+ describe: "Name your project",
73
+ type: "input"
74
+ },
75
+ template: {
76
+ describe: "Pick a template",
77
+ type: "list",
78
+ choices: templates
79
+ },
80
+ "mud-version": {
81
+ type: "input",
82
+ describe: "The version of MUD packages to use, defaults to latest",
83
+ default: package_default.version
84
+ }
85
+ }).then(async (args) => {
86
+ if (!args.name) throw new Error("No project name provided.");
87
+ const destDir = path.join(process.cwd(), args.name);
88
+ if (await exists(destDir)) {
89
+ throw new Error(`Target directory "${destDir}" already exists.`);
90
+ }
91
+ const sourceDir = path.join(__dirname2, "..", "templates", args.template);
92
+ const files = await glob("**/*", { cwd: sourceDir, dot: true });
93
+ for (const filename of files) {
94
+ const sourceFile = path.join(sourceDir, filename);
95
+ const destFile = path.join(destDir, filename);
96
+ await fs2.mkdir(path.dirname(destFile), { recursive: true });
97
+ if (/package\.json$/.test(sourceFile)) {
98
+ const source = await fs2.readFile(sourceFile, "utf-8");
99
+ await fs2.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), "utf-8");
100
+ } else if (/\.gitignore_$/.test(sourceFile)) {
101
+ await fs2.copyFile(sourceFile, destFile.replace(/_$/, ""));
102
+ } else {
103
+ await fs2.copyFile(sourceFile, destFile);
104
+ }
105
+ }
106
+ console.log(`
2
107
  New project created! Run it with:
3
108
 
4
- cd ${e.name}
109
+ cd ${args.name}
5
110
  pnpm install
6
111
  pnpm dev
7
112
 
8
113
  Have fun! For more info, check the docs at https://mud.dev/
9
- `)})}w();
114
+ `);
115
+ });
116
+ }
117
+ run();
10
118
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bin/cli.ts","../package.json","../src/common.ts","../src/exists.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport yargsInteractive from \"yargs-interactive\";\nimport glob from \"fast-glob\";\nimport packageJson from \"../../package.json\";\nimport { templates } from \"../common\";\nimport { exists } from \"../exists\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nasync function run() {\n yargsInteractive()\n .usage(\"$0 [args]\")\n .interactive({\n interactive: { default: true },\n name: {\n describe: \"Name your project\",\n type: \"input\",\n },\n template: {\n describe: \"Pick a template\",\n type: \"list\",\n choices: templates,\n },\n \"mud-version\": {\n type: \"input\",\n describe: \"The version of MUD packages to use, defaults to latest\",\n default: packageJson.version,\n },\n })\n .then(async (args) => {\n if (!args.name) throw new Error(\"No project name provided.\");\n\n const destDir = path.join(process.cwd(), args.name);\n if (await exists(destDir)) {\n throw new Error(`Target directory \"${destDir}\" already exists.`);\n }\n\n const sourceDir = path.join(__dirname, \"..\", \"templates\", args.template);\n const files = await glob(\"**/*\", { cwd: sourceDir, dot: true });\n\n for (const filename of files) {\n const sourceFile = path.join(sourceDir, filename);\n const destFile = path.join(destDir, filename);\n\n await fs.mkdir(path.dirname(destFile), { recursive: true });\n\n if (/package\\.json$/.test(sourceFile)) {\n const source = await fs.readFile(sourceFile, \"utf-8\");\n await fs.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), \"utf-8\");\n } else if (/\\.gitignore_$/.test(sourceFile)) {\n await fs.copyFile(sourceFile, destFile.replace(/_$/, \"\"));\n } else {\n await fs.copyFile(sourceFile, destFile);\n }\n }\n\n console.log(`\nNew project created! Run it with:\n\n cd ${args.name}\n pnpm install\n pnpm dev\n\nHave fun! For more info, check the docs at https://mud.dev/\n`);\n });\n}\n\nrun();\n","{\n \"name\": \"create-mud\",\n \"version\": \"2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30\",\n \"description\": \"Create a new MUD project\",\n \"license\": \"MIT\",\n \"author\": \"Lattice <mud@lattice.xyz>\",\n \"type\": \"module\",\n \"bin\": \"bin/cli.js\",\n \"files\": [\n \"bin\",\n \"dist\",\n \"templates\"\n ],\n \"scripts\": {\n \"build\": \"pnpm run build:js\",\n \"build:js\": \"tsup && pnpm run copy-templates\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"shx rm -rf dist\",\n \"copy-templates\": \"tsx ./scripts/copy-templates.ts\",\n \"dev\": \"tsup --watch\",\n \"prepublishOnly\": \"npm run clean && npm run build\",\n \"test\": \"shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs\",\n \"test:ci\": \"pnpm run test\",\n \"test:phaser\": \"bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react\": \"bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react-ecs\": \"bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:threejs\": \"bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:vanilla\": \"bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project\"\n },\n \"dependencies\": {\n \"fast-glob\": \"^3.3.3\",\n \"yargs-interactive\": \"^3.0.1\"\n },\n \"devDependencies\": {\n \"@types/yargs-interactive\": \"^2.1.6\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org\"\n }\n}\n","// We define these here to keep them in the order we want to present in the CLI.\n// Tests will ensure this list stays up to date.\nexport const templates = [\"react\", \"react-ecs\", \"phaser\", \"threejs\", \"vanilla\"];\n","import fs from \"node:fs/promises\";\n\nexport async function exists(path: string) {\n try {\n await fs.access(path);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":"AAAA,OAAOA,MAAQ,mBACf,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAOC,MAAsB,oBAC7B,OAAOC,MAAU,YCJjB,IAAAC,EAAA,CACE,KAAQ,aACR,QAAW,kDACX,YAAe,2BACf,QAAW,MACX,OAAU,4BACV,KAAQ,SACR,IAAO,aACP,MAAS,CACP,MACA,OACA,WACF,EACA,QAAW,CACT,MAAS,oBACT,WAAY,kCACZ,MAAS,oBACT,WAAY,kBACZ,iBAAkB,kCAClB,IAAO,eACP,eAAkB,iCAClB,KAAQ,sMACR,UAAW,gBACX,cAAe,iHACf,aAAc,gHACd,iBAAkB,oHAClB,eAAgB,kHAChB,eAAgB,iHAClB,EACA,aAAgB,CACd,YAAa,SACb,oBAAqB,QACvB,EACA,gBAAmB,CACjB,2BAA4B,QAC9B,EACA,cAAiB,CACf,OAAU,SACV,SAAY,4BACd,CACF,ECtCO,IAAMC,EAAY,CAAC,QAAS,YAAa,SAAU,UAAW,SAAS,ECF9E,OAAOC,MAAQ,mBAEf,eAAsBC,EAAOC,EAAc,CACzC,GAAI,CACF,aAAMF,EAAG,OAAOE,CAAI,EACb,EACT,MAAQ,CACN,MAAO,EACT,CACF,CHAA,IAAMC,EAAaC,EAAc,YAAY,GAAG,EAC1CC,EAAYC,EAAK,QAAQH,CAAU,EAEzC,eAAeI,GAAM,CACnBC,EAAiB,EACd,MAAM,WAAW,EACjB,YAAY,CACX,YAAa,CAAE,QAAS,EAAK,EAC7B,KAAM,CACJ,SAAU,oBACV,KAAM,OACR,EACA,SAAU,CACR,SAAU,kBACV,KAAM,OACN,QAASC,CACX,EACA,cAAe,CACb,KAAM,QACN,SAAU,yDACV,QAASC,EAAY,OACvB,CACF,CAAC,EACA,KAAK,MAAOC,GAAS,CACpB,GAAI,CAACA,EAAK,KAAM,MAAM,IAAI,MAAM,2BAA2B,EAE3D,IAAMC,EAAUN,EAAK,KAAK,QAAQ,IAAI,EAAGK,EAAK,IAAI,EAClD,GAAI,MAAME,EAAOD,CAAO,EACtB,MAAM,IAAI,MAAM,qBAAqBA,CAAO,mBAAmB,EAGjE,IAAME,EAAYR,EAAK,KAAKD,EAAW,KAAM,YAAaM,EAAK,QAAQ,EACjEI,EAAQ,MAAMC,EAAK,OAAQ,CAAE,IAAKF,EAAW,IAAK,EAAK,CAAC,EAE9D,QAAWG,KAAYF,EAAO,CAC5B,IAAMG,EAAaZ,EAAK,KAAKQ,EAAWG,CAAQ,EAC1CE,EAAWb,EAAK,KAAKM,EAASK,CAAQ,EAI5C,GAFA,MAAMG,EAAG,MAAMd,EAAK,QAAQa,CAAQ,EAAG,CAAE,UAAW,EAAK,CAAC,EAEtD,iBAAiB,KAAKD,CAAU,EAAG,CACrC,IAAMG,EAAS,MAAMD,EAAG,SAASF,EAAY,OAAO,EACpD,MAAME,EAAG,UAAUD,EAAUE,EAAO,WAAW,mBAAoBV,EAAK,UAAU,EAAG,OAAO,CAC9F,KAAW,gBAAgB,KAAKO,CAAU,EACxC,MAAME,EAAG,SAASF,EAAYC,EAAS,QAAQ,KAAM,EAAE,CAAC,EAExD,MAAMC,EAAG,SAASF,EAAYC,CAAQ,CAE1C,CAEA,QAAQ,IAAI;AAAA;AAAA;AAAA,OAGXR,EAAK,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,CAKf,CACG,CAAC,CACL,CAEAJ,EAAI","names":["fs","path","fileURLToPath","yargsInteractive","glob","package_default","templates","fs","exists","path","__filename","fileURLToPath","__dirname","path","run","yargsInteractive","templates","package_default","args","destDir","exists","sourceDir","files","glob","filename","sourceFile","destFile","fs","source"]}
1
+ {"version":3,"sources":["../src/bin/cli.ts","../package.json","../src/common.ts","../src/exists.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport yargsInteractive from \"yargs-interactive\";\nimport glob from \"fast-glob\";\nimport packageJson from \"../../package.json\";\nimport { templates } from \"../common\";\nimport { exists } from \"../exists\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nasync function run() {\n yargsInteractive()\n .usage(\"$0 [args]\")\n .interactive({\n interactive: { default: true },\n name: {\n describe: \"Name your project\",\n type: \"input\",\n },\n template: {\n describe: \"Pick a template\",\n type: \"list\",\n choices: templates,\n },\n \"mud-version\": {\n type: \"input\",\n describe: \"The version of MUD packages to use, defaults to latest\",\n default: packageJson.version,\n },\n })\n .then(async (args) => {\n if (!args.name) throw new Error(\"No project name provided.\");\n\n const destDir = path.join(process.cwd(), args.name);\n if (await exists(destDir)) {\n throw new Error(`Target directory \"${destDir}\" already exists.`);\n }\n\n const sourceDir = path.join(__dirname, \"..\", \"templates\", args.template);\n const files = await glob(\"**/*\", { cwd: sourceDir, dot: true });\n\n for (const filename of files) {\n const sourceFile = path.join(sourceDir, filename);\n const destFile = path.join(destDir, filename);\n\n await fs.mkdir(path.dirname(destFile), { recursive: true });\n\n if (/package\\.json$/.test(sourceFile)) {\n const source = await fs.readFile(sourceFile, \"utf-8\");\n await fs.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), \"utf-8\");\n } else if (/\\.gitignore_$/.test(sourceFile)) {\n await fs.copyFile(sourceFile, destFile.replace(/_$/, \"\"));\n } else {\n await fs.copyFile(sourceFile, destFile);\n }\n }\n\n console.log(`\nNew project created! Run it with:\n\n cd ${args.name}\n pnpm install\n pnpm dev\n\nHave fun! For more info, check the docs at https://mud.dev/\n`);\n });\n}\n\nrun();\n","{\n \"name\": \"create-mud\",\n \"version\": \"2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2\",\n \"description\": \"Create a new MUD project\",\n \"license\": \"MIT\",\n \"author\": \"Lattice <mud@lattice.xyz>\",\n \"type\": \"module\",\n \"bin\": \"bin/cli.js\",\n \"files\": [\n \"bin\",\n \"dist\",\n \"templates\"\n ],\n \"scripts\": {\n \"build\": \"pnpm run build:js\",\n \"build:js\": \"tsup && pnpm run copy-templates\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"shx rm -rf dist\",\n \"copy-templates\": \"tsx ./scripts/copy-templates.ts\",\n \"dev\": \"tsup --watch\",\n \"prepublishOnly\": \"npm run clean && npm run build\",\n \"test\": \"shx rm -rf test-project && pnpm run copy-templates && pnpm vitest --run && pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs\",\n \"test:ci\": \"pnpm run test\",\n \"test:phaser\": \"bin/cli.js --name test-project --template phaser && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react\": \"bin/cli.js --name test-project --template react && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:react-ecs\": \"bin/cli.js --name test-project --template react-ecs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:threejs\": \"bin/cli.js --name test-project --template threejs && pnpm --dir test-project install && shx rm -rf test-project\",\n \"test:vanilla\": \"bin/cli.js --name test-project --template vanilla && pnpm --dir test-project install && shx rm -rf test-project\"\n },\n \"dependencies\": {\n \"fast-glob\": \"^3.3.3\",\n \"yargs-interactive\": \"^3.0.1\"\n },\n \"devDependencies\": {\n \"@types/yargs-interactive\": \"^2.1.6\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org\"\n }\n}\n","// We define these here to keep them in the order we want to present in the CLI.\n// Tests will ensure this list stays up to date.\nexport const templates = [\"react\", \"react-ecs\", \"phaser\", \"threejs\", \"vanilla\"];\n","import fs from \"node:fs/promises\";\n\nexport async function exists(path: string) {\n try {\n await fs.access(path);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAAA,OA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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mud",
3
- "version": "2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30",
3
+ "version": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
4
4
  "description": "Create a new MUD project",
5
5
  "license": "MIT",
6
6
  "author": "Lattice <mud@lattice.xyz>",