create-dreamer-app 0.0.0-stage → 1.0.2
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 +15 -0
- package/README.md +98 -2
- package/index.js +94 -0
- package/package.json +12 -4
- package/template/package.json +27 -0
- package/template/src/assets/disco-dreamer.svg +4 -0
- package/template/src/components/GameScreen/index.tsx +10 -0
- package/template/src/components/Message/index.tsx +6 -0
- package/template/src/index.html +13 -0
- package/template/src/index.tsx +8 -0
- package/template/src/main.css +17 -0
- package/template/src/main.ts +6 -0
- package/template/tsconfig.json +24 -0
- package/template/vite.config.js +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Glorbicon
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-dreamer-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start building with **Disco Dreamer** in a few commands.
|
|
4
|
+
|
|
5
|
+
Scaffold a starter app with TypeScript, TSX components, and Vite already configured. The CLI creates your project and installs its dependencies so you can get straight to your first scene.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx create-dreamer-app@latest my-dreamer-app
|
|
11
|
+
cd my-dreamer-app
|
|
12
|
+
npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Open the local URL printed by Vite. The development server uses port `3000` by default.
|
|
16
|
+
|
|
17
|
+
**Requirements:** Node.js `20.19+` within the Node 20 release line, or `22.12+`, and npm.
|
|
18
|
+
|
|
19
|
+
## What's included
|
|
20
|
+
|
|
21
|
+
- **Disco Dreamer** with a starter scene and text component.
|
|
22
|
+
- **TypeScript and TSX** with strict type checking.
|
|
23
|
+
- **Vite** for local development and production builds.
|
|
24
|
+
- **Source aliases** so you can import from `@/` instead of navigating relative paths.
|
|
25
|
+
- A full-page canvas with basic styles.
|
|
26
|
+
|
|
27
|
+
## Make it yours
|
|
28
|
+
|
|
29
|
+
Start in `src/components/Message/index.tsx` to change the greeting:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Text } from "discodreamer";
|
|
33
|
+
|
|
34
|
+
export function Message() {
|
|
35
|
+
return <Text value="Hello, Dreamer!" />;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Add components to `src/components/GameScreen/index.tsx` to build out your scene. Use the `@/` alias anywhere in your TypeScript source:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Message } from "@/components/Message";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Project structure
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
my-dreamer-app/
|
|
49
|
+
├── src/
|
|
50
|
+
│ ├── assets/
|
|
51
|
+
│ │ └── disco-dreamer.svg
|
|
52
|
+
│ ├── components/
|
|
53
|
+
│ │ ├── GameScreen/index.tsx
|
|
54
|
+
│ │ └── Message/index.tsx
|
|
55
|
+
│ ├── index.html # HTML page and canvas
|
|
56
|
+
│ ├── index.tsx # Root scene component
|
|
57
|
+
│ ├── main.ts # App registration
|
|
58
|
+
│ └── main.css # Canvas and page styles
|
|
59
|
+
├── package.json
|
|
60
|
+
├── tsconfig.json
|
|
61
|
+
└── vite.config.js
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
Run these inside your generated project:
|
|
67
|
+
|
|
68
|
+
| Command | Description |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `npm run dev` | Start the development server. |
|
|
71
|
+
| `npm run typecheck` | Check TypeScript without emitting files. |
|
|
72
|
+
| `npm run build` | Check types and build the app into `dist/`. |
|
|
73
|
+
| `npm run preview` | Preview the production build locally after building. |
|
|
74
|
+
|
|
75
|
+
## CLI options
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npx create-dreamer-app@latest [directory] [--skip-install]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Omit the directory to choose a name interactively. The destination must be a new or empty directory.
|
|
82
|
+
|
|
83
|
+
| Option | Description |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `--skip-install` | Create the project without installing dependencies. |
|
|
86
|
+
| `-h`, `--help` | Show usage information. |
|
|
87
|
+
|
|
88
|
+
To install dependencies yourself:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
npx create-dreamer-app@latest my-dreamer-app --skip-install
|
|
92
|
+
cd my-dreamer-app
|
|
93
|
+
npm install
|
|
94
|
+
npm run dev
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
ISC
|
package/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const readline = require("node:readline/promises");
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
|
|
8
|
+
const usage = `Usage: create-dreamer-app [directory] [--skip-install]
|
|
9
|
+
|
|
10
|
+
Create a Disco Dreamer app and install its dependencies.
|
|
11
|
+
If no directory is supplied, you will be prompted for one.
|
|
12
|
+
|
|
13
|
+
Options:
|
|
14
|
+
--skip-install Create the project without running npm install
|
|
15
|
+
-h, --help Show this help message
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
npx create-dreamer-app my-dreamer-app`;
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
23
|
+
console.log(usage);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const unknownOption = args.find((arg) => arg.startsWith("-") && arg !== "--skip-install");
|
|
28
|
+
if (unknownOption) throw new Error(`Unknown option: ${unknownOption}\n\n${usage}`);
|
|
29
|
+
const directories = args.filter((arg) => arg !== "--skip-install");
|
|
30
|
+
if (directories.length > 1) throw new Error(`Supply only one project directory.\n\n${usage}`);
|
|
31
|
+
|
|
32
|
+
let directory = directories[0];
|
|
33
|
+
if (directory === undefined) {
|
|
34
|
+
if (!process.stdin.isTTY) throw new Error(`Supply a project directory.\n\n${usage}`);
|
|
35
|
+
const prompt = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
36
|
+
try {
|
|
37
|
+
directory = (await prompt.question("Project directory (my-dreamer-app): ")).trim() || "my-dreamer-app";
|
|
38
|
+
} finally {
|
|
39
|
+
prompt.close();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!directory.trim()) throw new Error("The project directory cannot be empty.");
|
|
43
|
+
|
|
44
|
+
const destination = path.resolve(directory);
|
|
45
|
+
const name = path.basename(destination).toLowerCase().replace(/[^a-z0-9._-]+/g, "-");
|
|
46
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/.test(name) || name.length > 214 || ["node_modules", "favicon.ico"].includes(name)) {
|
|
47
|
+
throw new Error("Choose a directory whose name starts with a letter or number and can be used as an npm package name.");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Refuse symlinks and nonempty directories before copying any files.
|
|
51
|
+
try {
|
|
52
|
+
const stat = await fs.lstat(destination);
|
|
53
|
+
if (!stat.isDirectory() || (await fs.readdir(destination)).length > 0) {
|
|
54
|
+
throw new Error(`Destination already exists and is not an empty directory: ${destination}`);
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.code !== "ENOENT") throw error;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(`Creating ${name} in ${destination}...`);
|
|
61
|
+
await fs.cp(path.join(__dirname, "template"), destination, {
|
|
62
|
+
recursive: true,
|
|
63
|
+
force: false,
|
|
64
|
+
errorOnExist: true,
|
|
65
|
+
filter: (source) => ![".DS_Store", "node_modules", "dist"].includes(path.basename(source)),
|
|
66
|
+
});
|
|
67
|
+
const packagePath = path.join(destination, "package.json");
|
|
68
|
+
const manifest = JSON.parse(await fs.readFile(packagePath, "utf8"));
|
|
69
|
+
manifest.name = name;
|
|
70
|
+
await fs.writeFile(packagePath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
71
|
+
|
|
72
|
+
const skipInstall = args.includes("--skip-install");
|
|
73
|
+
if (!skipInstall) {
|
|
74
|
+
console.log("Installing dependencies...");
|
|
75
|
+
const result = spawnSync(process.platform === "win32" ? "npm.cmd" : "npm", ["install"], {
|
|
76
|
+
cwd: destination,
|
|
77
|
+
stdio: "inherit",
|
|
78
|
+
shell: process.platform === "win32",
|
|
79
|
+
});
|
|
80
|
+
if (result.error || result.status !== 0) {
|
|
81
|
+
throw new Error(`Dependency installation failed${result.error ? `: ${result.error.message}` : ""}. Your project files are saved in ${destination}. Run npm install there to retry.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log(`\nCreated ${name}!\n\nNext steps:`);
|
|
86
|
+
if (destination !== process.cwd()) console.log(` cd ${JSON.stringify(path.relative(process.cwd(), destination))}`);
|
|
87
|
+
if (skipInstall) console.log(" npm install");
|
|
88
|
+
console.log(" npm run dev");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main().catch((error) => {
|
|
92
|
+
console.error(`\nError: ${error.message}`);
|
|
93
|
+
process.exitCode = 1;
|
|
94
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dreamer-app",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "The scaffolding application for using Disco Dreamer.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-dreamer-app": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
11
|
+
},
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC"
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mydreamerapp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
9
|
+
"build": "npm run typecheck && vite build",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^26.6.4",
|
|
21
|
+
"typescript": "^7.0.2",
|
|
22
|
+
"vite": "^8.3.2"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"discodreamer": "^1.0.0"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="280" height="64" viewBox="0 0 280 64" role="img" aria-labelledby="title">
|
|
2
|
+
<title id="title">Disco Dreamer</title>
|
|
3
|
+
<text x="140" y="32" dominant-baseline="middle" text-anchor="middle" fill="#a78bfa" font-family="system-ui, sans-serif" font-size="32" font-weight="700">Disco Dreamer</text>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>My Dreamer App!</title>
|
|
7
|
+
<link rel="stylesheet" href="./main.css">
|
|
8
|
+
<script type="module" src="./main.ts"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<canvas id="c"></canvas>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./src",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"noEmit": true,
|
|
7
|
+
"target": "esnext",
|
|
8
|
+
"lib": ["esnext", "DOM"],
|
|
9
|
+
"types": ["vite/client"],
|
|
10
|
+
"noUncheckedIndexedAccess": true,
|
|
11
|
+
"exactOptionalPropertyTypes": false,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"jsx": "preserve",
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noUncheckedSideEffectImports": true,
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["./src/*"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
root: "src",
|
|
6
|
+
base: "./",
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
oxc: {
|
|
13
|
+
jsxInject: 'import { DreamFactory as __DreamFactory } from "discodreamer"',
|
|
14
|
+
jsx: {
|
|
15
|
+
runtime: "classic",
|
|
16
|
+
pragma: "__DreamFactory",
|
|
17
|
+
pure: false,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
server: {
|
|
21
|
+
port: 3000,
|
|
22
|
+
},
|
|
23
|
+
build: {
|
|
24
|
+
outDir: "../dist",
|
|
25
|
+
emptyOutDir: true,
|
|
26
|
+
},
|
|
27
|
+
});
|