-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into revert-3477-revert-34…
…39-holic/react-entrykit-stash
- Loading branch information
Showing
20 changed files
with
1,249 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-mud": patch | ||
--- | ||
|
||
Replaced internal usage of `create-create-app` with a simpler recursive copy operation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ public/ | |
|
||
# End of https://www.gitignore.io/api/node | ||
|
||
templates | ||
|
||
# Created by `pnpm test` | ||
test-project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
// workaround for https://github.com/pnpm/pnpm/issues/1801 | ||
import "../dist/cli.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,29 +4,35 @@ | |
"description": "Create a new MUD project", | ||
"license": "MIT", | ||
"author": "Lattice <[email protected]>", | ||
"bin": "dist/cli.js", | ||
"type": "module", | ||
"bin": "bin/cli.js", | ||
"files": [ | ||
"dist" | ||
"bin", | ||
"dist", | ||
"templates" | ||
], | ||
"scripts": { | ||
"build": "pnpm run build:js", | ||
"build:js": "tsup && tsx ./scripts/copy-templates.ts", | ||
"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": "pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs", | ||
"test": "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": "dist/cli.js test-project --template phaser && shx rm -rf test-project", | ||
"test:react": "dist/cli.js test-project --template react && shx rm -rf test-project", | ||
"test:react-ecs": "dist/cli.js test-project --template react-ecs && shx rm -rf test-project", | ||
"test:threejs": "dist/cli.js test-project --template threejs && shx rm -rf test-project", | ||
"test:vanilla": "dist/cli.js test-project --template vanilla && shx rm -rf test-project" | ||
"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": { | ||
"create-create-app": "git+https://github.com/holic/create-create-app#74376c59b48a04aabbe94d9cacfe9cb1cecccd63" | ||
"fast-glob": "^3.3.3", | ||
"yargs-interactive": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/yargs-interactive": "^2.1.6", | ||
"execa": "^7.0.0" | ||
}, | ||
"publishConfig": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import yargsInteractive from "yargs-interactive"; | ||
import glob from "fast-glob"; | ||
import packageJson from "../../package.json"; | ||
import { templates } from "../common"; | ||
import { exists } from "../exists"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
async function run() { | ||
yargsInteractive() | ||
.usage("$0 [args]") | ||
.interactive({ | ||
interactive: { default: true }, | ||
name: { | ||
describe: "Name your project", | ||
type: "input", | ||
}, | ||
template: { | ||
describe: "Pick a template", | ||
type: "list", | ||
choices: templates, | ||
}, | ||
"mud-version": { | ||
type: "input", | ||
describe: "The version of MUD packages to use, defaults to latest", | ||
default: packageJson.version, | ||
}, | ||
}) | ||
.then(async (args) => { | ||
if (!args.name) throw new Error("No project name provided."); | ||
|
||
const destDir = path.join(process.cwd(), args.name); | ||
if (await exists(destDir)) { | ||
throw new Error(`Target directory "${destDir}" already exists.`); | ||
} | ||
|
||
const sourceDir = path.join(__dirname, "..", "templates", args.template); | ||
const files = await glob("**/*", { cwd: sourceDir, dot: true }); | ||
|
||
for (const filename of files) { | ||
const sourceFile = path.join(sourceDir, filename); | ||
const destFile = path.join(destDir, filename); | ||
|
||
await fs.mkdir(path.dirname(destFile), { recursive: true }); | ||
|
||
if (/package\.json$/.test(sourceFile)) { | ||
const source = await fs.readFile(sourceFile, "utf-8"); | ||
await fs.writeFile(destFile, source.replaceAll(/{{mud-version}}/g, args.mudVersion), "utf-8"); | ||
} else { | ||
await fs.copyFile(sourceFile, destFile); | ||
} | ||
} | ||
|
||
console.log(` | ||
New project created! Run it with: | ||
cd ${args.name} | ||
pnpm install | ||
pnpm dev | ||
Have fun! For more info, check the docs at https://mud.dev/ | ||
`); | ||
}); | ||
} | ||
|
||
run(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { glob } from "glob"; | ||
import { templates } from "./common"; | ||
|
||
describe("templates", () => { | ||
it("matches what is in the file system", async () => { | ||
const availableTemplates = await glob("*", { | ||
maxDepth: 1, | ||
cwd: `${__dirname}/../templates`, | ||
}); | ||
expect(templates).toEqual(expect.arrayContaining(availableTemplates)); | ||
expect(availableTemplates).toEqual(expect.arrayContaining(templates)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// We define these here to keep them in the order we want to present in the CLI. | ||
// Tests will ensure this list stays up to date. | ||
export const templates = ["react", "react-ecs", "phaser", "threejs", "vanilla"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import fs from "node:fs/promises"; | ||
|
||
export async function exists(path: string) { | ||
try { | ||
await fs.access(path); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.