create-airjam 0.1.5 → 0.1.7
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/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { program } from "commander";
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
5
|
import fs from "fs-extra";
|
|
7
6
|
import kleur from "kleur";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
8
|
import path from "path";
|
|
9
9
|
import { fileURLToPath } from "url";
|
|
10
10
|
import prompts from "prompts";
|
|
@@ -29,7 +29,12 @@ async function main() {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const targetDir = path.resolve(process.cwd(), projectName);
|
|
32
|
-
const templateDir = path.resolve(
|
|
32
|
+
const templateDir = path.resolve(
|
|
33
|
+
__dirname,
|
|
34
|
+
"..",
|
|
35
|
+
"templates",
|
|
36
|
+
options.template
|
|
37
|
+
);
|
|
33
38
|
if (!fs.existsSync(templateDir)) {
|
|
34
39
|
console.log(kleur.red(`Template "${options.template}" not found`));
|
|
35
40
|
process.exit(1);
|
|
@@ -92,6 +97,7 @@ Creating project in ${targetDir}...
|
|
|
92
97
|
});
|
|
93
98
|
console.log(kleur.green("\n\u2713 Dependencies installed successfully!\n"));
|
|
94
99
|
} catch (error) {
|
|
100
|
+
console.error(error);
|
|
95
101
|
console.log(
|
|
96
102
|
kleur.yellow(
|
|
97
103
|
"\n\u26A0 Failed to install dependencies automatically. Please run 'pnpm install' manually.\n"
|
|
@@ -101,12 +107,18 @@ Creating project in ${targetDir}...
|
|
|
101
107
|
console.log("Next steps:\n");
|
|
102
108
|
console.log(kleur.cyan(` cd ${projectName}`));
|
|
103
109
|
console.log(kleur.cyan(" cp .env.example .env"));
|
|
104
|
-
console.log(
|
|
110
|
+
console.log(
|
|
111
|
+
kleur.cyan(
|
|
112
|
+
" # Edit .env and set AIR_JAM_MASTER_KEY (optional for local dev)"
|
|
113
|
+
)
|
|
114
|
+
);
|
|
105
115
|
console.log(kleur.cyan(" pnpm run dev:server # Terminal 1 - Start server"));
|
|
106
116
|
console.log(kleur.cyan(" pnpm run dev # Terminal 2 - Start game"));
|
|
107
117
|
console.log("");
|
|
108
118
|
console.log(
|
|
109
|
-
kleur.dim(
|
|
119
|
+
kleur.dim(
|
|
120
|
+
"Then open http://localhost:5173 and scan the QR code with your phone!"
|
|
121
|
+
)
|
|
110
122
|
);
|
|
111
123
|
}
|
|
112
124
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-airjam",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "CLI to scaffold Air Jam game projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"extract-docs": "tsx scripts/extract-docs.ts",
|
|
33
33
|
"build": "pnpm extract-docs && tsup",
|
|
34
34
|
"dev": "tsup --watch",
|
|
35
|
-
"prepublishOnly": "pnpm build"
|
|
35
|
+
"prepublishOnly": "node scripts/prepublish.js && pnpm build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"commander": "^14.0.0",
|
|
@@ -8,19 +8,17 @@
|
|
|
8
8
|
"dev:server": "air-jam-server",
|
|
9
9
|
"build": "tsc && vite build",
|
|
10
10
|
"preview": "vite preview",
|
|
11
|
-
"typecheck": "tsc --noEmit"
|
|
12
|
-
"install:standalone": "pnpm install --ignore-workspace",
|
|
13
|
-
"prepublishOnly": "node scripts/prepublish.js"
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
14
12
|
},
|
|
15
13
|
"dependencies": {
|
|
16
|
-
"@air-jam/sdk": "
|
|
14
|
+
"@air-jam/sdk": "^0.1.2",
|
|
17
15
|
"react": "^19.0.0",
|
|
18
16
|
"react-dom": "^19.0.0",
|
|
19
17
|
"react-router-dom": "^7.0.0",
|
|
20
18
|
"zod": "^4.2.1"
|
|
21
19
|
},
|
|
22
20
|
"devDependencies": {
|
|
23
|
-
"@air-jam/server": "
|
|
21
|
+
"@air-jam/server": "^0.1.3",
|
|
24
22
|
"@eslint/js": "^9.39.1",
|
|
25
23
|
"@tailwindcss/vite": "^4.0.0",
|
|
26
24
|
"@types/react": "^19.0.0",
|
|
@@ -11,9 +11,6 @@ export default defineConfig({
|
|
|
11
11
|
resolve: {
|
|
12
12
|
alias: {
|
|
13
13
|
"@": path.resolve(__dirname, "./src"),
|
|
14
|
-
// Resolve SDK to source files for instant updates during development
|
|
15
|
-
// This only works when running in the monorepo structure
|
|
16
|
-
"@air-jam/sdk": path.resolve(__dirname, "../../../sdk/src"),
|
|
17
14
|
},
|
|
18
15
|
},
|
|
19
16
|
server: {
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Prepublish script for Air Jam games
|
|
4
|
-
*
|
|
5
|
-
* Replaces workspace:* protocol with actual npm versions for publishing.
|
|
6
|
-
* Removes monorepo-specific source file resolutions from vite.config.ts and tsconfig.json.
|
|
7
|
-
* This allows us to use the workspace SDK/server locally but publish with npm versions.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
|
|
14
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
-
const __dirname = dirname(__filename);
|
|
16
|
-
|
|
17
|
-
const gamePackagePath = join(__dirname, "../package.json");
|
|
18
|
-
const viteConfigPath = join(__dirname, "../vite.config.ts");
|
|
19
|
-
const tsconfigPath = join(__dirname, "../tsconfig.json");
|
|
20
|
-
|
|
21
|
-
async function getPackageVersion(packageName) {
|
|
22
|
-
try {
|
|
23
|
-
// Try to read from node_modules (when installed)
|
|
24
|
-
const nodeModulesPath = join(
|
|
25
|
-
__dirname,
|
|
26
|
-
"../node_modules",
|
|
27
|
-
packageName,
|
|
28
|
-
"package.json",
|
|
29
|
-
);
|
|
30
|
-
const packageJson = JSON.parse(await readFile(nodeModulesPath, "utf-8"));
|
|
31
|
-
return packageJson.version;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
// If not in node_modules, try to find it in the monorepo structure
|
|
34
|
-
// This handles the case when running in the monorepo
|
|
35
|
-
try {
|
|
36
|
-
const monorepoPath = join(
|
|
37
|
-
__dirname,
|
|
38
|
-
"../../../../",
|
|
39
|
-
packageName.replace("@air-jam/", ""),
|
|
40
|
-
"package.json",
|
|
41
|
-
);
|
|
42
|
-
const packageJson = JSON.parse(await readFile(monorepoPath, "utf-8"));
|
|
43
|
-
return packageJson.version;
|
|
44
|
-
} catch (monorepoError) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Could not find version for ${packageName}. Make sure it's installed.`,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function removeMonorepoPaths() {
|
|
53
|
-
try {
|
|
54
|
-
// Remove SDK alias from vite.config.ts
|
|
55
|
-
let viteConfig = await readFile(viteConfigPath, "utf-8");
|
|
56
|
-
const originalViteConfig = viteConfig;
|
|
57
|
-
|
|
58
|
-
// Remove lines containing the SDK alias and its comments
|
|
59
|
-
const lines = viteConfig.split("\n");
|
|
60
|
-
const filteredLines = [];
|
|
61
|
-
let skipNext = false;
|
|
62
|
-
|
|
63
|
-
for (let i = 0; i < lines.length; i++) {
|
|
64
|
-
const line = lines[i];
|
|
65
|
-
// Skip comment lines about SDK source resolution
|
|
66
|
-
if (
|
|
67
|
-
line.includes("Resolve SDK to source files") ||
|
|
68
|
-
line.includes("This only works when running in the monorepo")
|
|
69
|
-
) {
|
|
70
|
-
skipNext = true;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
// Skip the actual SDK alias line
|
|
74
|
-
if (
|
|
75
|
-
line.includes('"@air-jam/sdk"') &&
|
|
76
|
-
line.includes("../../../sdk/src")
|
|
77
|
-
) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
filteredLines.push(line);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
viteConfig = filteredLines.join("\n");
|
|
84
|
-
|
|
85
|
-
if (viteConfig !== originalViteConfig) {
|
|
86
|
-
await writeFile(viteConfigPath, viteConfig, "utf-8");
|
|
87
|
-
console.log("✓ Removed monorepo SDK alias from vite.config.ts");
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.warn("Warning: Could not update vite.config.ts:", error.message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
// Remove SDK paths from tsconfig.json
|
|
95
|
-
const tsconfig = JSON.parse(await readFile(tsconfigPath, "utf-8"));
|
|
96
|
-
let updated = false;
|
|
97
|
-
|
|
98
|
-
if (tsconfig.compilerOptions?.paths) {
|
|
99
|
-
// Remove @air-jam/sdk paths
|
|
100
|
-
if (tsconfig.compilerOptions.paths["@air-jam/sdk"]) {
|
|
101
|
-
delete tsconfig.compilerOptions.paths["@air-jam/sdk"];
|
|
102
|
-
updated = true;
|
|
103
|
-
}
|
|
104
|
-
if (tsconfig.compilerOptions.paths["@air-jam/sdk/*"]) {
|
|
105
|
-
delete tsconfig.compilerOptions.paths["@air-jam/sdk/*"];
|
|
106
|
-
updated = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Remove SDK source from include array
|
|
111
|
-
if (Array.isArray(tsconfig.include)) {
|
|
112
|
-
const originalLength = tsconfig.include.length;
|
|
113
|
-
tsconfig.include = tsconfig.include.filter(
|
|
114
|
-
(item) => !item.includes("../../../sdk/src"),
|
|
115
|
-
);
|
|
116
|
-
if (tsconfig.include.length !== originalLength) {
|
|
117
|
-
updated = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (updated) {
|
|
122
|
-
await writeFile(
|
|
123
|
-
tsconfigPath,
|
|
124
|
-
JSON.stringify(tsconfig, null, 2) + "\n",
|
|
125
|
-
"utf-8",
|
|
126
|
-
);
|
|
127
|
-
console.log("✓ Removed monorepo SDK paths from tsconfig.json");
|
|
128
|
-
}
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.warn("Warning: Could not update tsconfig.json:", error.message);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async function main() {
|
|
135
|
-
try {
|
|
136
|
-
// Read game package.json
|
|
137
|
-
const gamePackage = JSON.parse(await readFile(gamePackagePath, "utf-8"));
|
|
138
|
-
let updated = false;
|
|
139
|
-
|
|
140
|
-
// Update @air-jam/sdk in dependencies
|
|
141
|
-
if (gamePackage.dependencies?.["@air-jam/sdk"] === "workspace:*") {
|
|
142
|
-
const sdkVersion = await getPackageVersion("@air-jam/sdk");
|
|
143
|
-
gamePackage.dependencies["@air-jam/sdk"] = `^${sdkVersion}`;
|
|
144
|
-
updated = true;
|
|
145
|
-
console.log(
|
|
146
|
-
`✓ Updated @air-jam/sdk dependency to ^${sdkVersion} for publishing`,
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Update @air-jam/server in devDependencies
|
|
151
|
-
if (gamePackage.devDependencies?.["@air-jam/server"] === "workspace:*") {
|
|
152
|
-
const serverVersion = await getPackageVersion("@air-jam/server");
|
|
153
|
-
gamePackage.devDependencies["@air-jam/server"] = `^${serverVersion}`;
|
|
154
|
-
updated = true;
|
|
155
|
-
console.log(
|
|
156
|
-
`✓ Updated @air-jam/server devDependency to ^${serverVersion} for publishing`,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (updated) {
|
|
161
|
-
// Write back
|
|
162
|
-
await writeFile(
|
|
163
|
-
gamePackagePath,
|
|
164
|
-
JSON.stringify(gamePackage, null, 2) + "\n",
|
|
165
|
-
"utf-8",
|
|
166
|
-
);
|
|
167
|
-
} else {
|
|
168
|
-
console.log("No workspace dependencies to update");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Remove monorepo-specific paths from config files
|
|
172
|
-
await removeMonorepoPaths();
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error("Error in prepublish script:", error);
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
main();
|