auramaxx 0.1.4 → 0.1.6

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/bin/auramaxx.js CHANGED
@@ -1440,8 +1440,7 @@ async function main() {
1440
1440
 
1441
1441
  const inferredStartFlags = new Set(['--debug', '--terminal', '--headless', '--background', '--daemon', '-d']);
1442
1442
  if (cmd && inferredStartFlags.has(cmd)) {
1443
- const defaultCommand = resolveDefaultCommand();
1444
- if (defaultCommand === 'start') {
1443
+ if (isCommandAvailable('start')) {
1445
1444
  inferredCommand = true;
1446
1445
  args.unshift(cmd);
1447
1446
  cmd = 'start';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auramaxx",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "AuraJS CLI for creating, playing, and publishing JavaScript-first games.",
5
5
  "keywords": [
6
6
  "aurajs",
@@ -30,6 +30,7 @@
30
30
  "src/server/cli/commands/make.ts",
31
31
  "src/server/cli/commands/play.ts",
32
32
  "src/server/cli/commands/publish.ts",
33
+ "src/server/cli/lib/aurajs-project.ts",
33
34
  "src/server/cli/lib/published-game-integrity.ts",
34
35
  "src/server/cli/lib/prompt.ts",
35
36
  "src/server/cli/lib/theme.ts"
@@ -9,6 +9,7 @@ const TEMPLATE_OPTIONS = [
9
9
  { value: '2d', label: '[2D] Adventure', aliases: ['1', '2', '2d', '2d-adventure', 'adventure-2d'] },
10
10
  { value: '3d', label: '[3D] Adventure', aliases: ['3', '3d', '3d-adventure', 'adventure-3d'] },
11
11
  { value: 'multiplayer', label: '[MP] Multiplayer', aliases: ['4', 'mp', 'multiplayer', 'room', 'room-code', 'local-multiplayer'] },
12
+ { value: 'custom', label: '[Custom] Enter AuraJS template id', aliases: ['5', 'c', 'custom', 'other'] },
12
13
  ];
13
14
  const TEMPLATE_ALIASES: Record<string, string> = {
14
15
  '2d': '2d',
@@ -99,7 +100,17 @@ async function resolveTemplate(initialTemplate: string | null): Promise<string>
99
100
  if (normalized) {
100
101
  return normalized;
101
102
  }
102
- return promptSelect(' Starter template', TEMPLATE_OPTIONS, '2d');
103
+
104
+ const selected = await promptSelect(' Starter template', TEMPLATE_OPTIONS, '2d');
105
+ if (selected !== 'custom') {
106
+ return selected;
107
+ }
108
+
109
+ while (true) {
110
+ const answer = normalizeTemplate(await promptInput(' AuraJS template id'));
111
+ if (answer) return answer;
112
+ console.error(' Template id is required.');
113
+ }
103
114
  }
104
115
 
105
116
  async function main() {
@@ -107,13 +118,16 @@ async function main() {
107
118
 
108
119
  if (parsed.help) {
109
120
  printBanner('CREATE');
110
- console.log(` ${paint('Usage:', ANSI.bold)} auramaxx create [name] [--template <2d|3d|multiplayer>] [--skip-install]`);
121
+ console.log(` ${paint('Usage:', ANSI.bold)} auramaxx create [name] [--template <slug>] [--skip-install]`);
111
122
  console.log('');
112
123
  console.log(' Styled wrapper around AuraJS create scaffolding.');
113
124
  console.log(` ${paint('Examples:', ANSI.dim)}`);
114
125
  console.log(' auramaxx create my-game --template 2d');
115
126
  console.log(' auramaxx create my-game --template 3d');
116
127
  console.log(' auramaxx create my-room-game --template multiplayer');
128
+ console.log(' auramaxx create my-retro --template retro-topdown-adventure');
129
+ console.log('');
130
+ console.log(' The starter prompt shows common presets and also supports a custom AuraJS template id.');
117
131
  console.log('');
118
132
  return;
119
133
  }
@@ -1,14 +1,5 @@
1
- import { execFileSync } from 'child_process';
2
- import { existsSync } from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
1
  import { printBanner, paint, ANSI } from '../lib/theme';
6
-
7
- const COMMAND_DIR = path.dirname(fileURLToPath(import.meta.url));
8
- const LOCAL_AURAJS_CLI = path.resolve(
9
- COMMAND_DIR,
10
- '../../../../../packages/aurascript/src/cli/src/cli.mjs',
11
- );
2
+ import { delegateToAuraJsProjectCommand } from '../lib/aurajs-project';
12
3
 
13
4
  function parseArgs(argv: string[]) {
14
5
  for (const arg of argv) {
@@ -22,19 +13,6 @@ function parseArgs(argv: string[]) {
22
13
  };
23
14
  }
24
15
 
25
- function resolveInvocationCwd(): string {
26
- const forwardedCwd = process.env.AURA_INVOKE_CWD;
27
- if (forwardedCwd && path.isAbsolute(forwardedCwd)) {
28
- return forwardedCwd;
29
- }
30
-
31
- const shellPwd = process.env.PWD;
32
- if (shellPwd && path.isAbsolute(shellPwd)) {
33
- return shellPwd;
34
- }
35
- return process.cwd();
36
- }
37
-
38
16
  async function main() {
39
17
  const parsed = parseArgs(process.argv.slice(2));
40
18
 
@@ -56,32 +34,7 @@ async function main() {
56
34
  return;
57
35
  }
58
36
 
59
- const invocationCwd = resolveInvocationCwd();
60
- const auraArgs = ['make', ...parsed.passthrough];
61
-
62
- try {
63
- if (existsSync(LOCAL_AURAJS_CLI)) {
64
- execFileSync(process.execPath, [LOCAL_AURAJS_CLI, ...auraArgs], {
65
- cwd: invocationCwd,
66
- stdio: 'inherit',
67
- env: process.env,
68
- });
69
- } else {
70
- execFileSync(
71
- 'npm',
72
- ['exec', '--yes', '--package', '@auraindustry/aurajs', '--', 'aura', ...auraArgs],
73
- {
74
- cwd: invocationCwd,
75
- stdio: 'inherit',
76
- env: process.env,
77
- },
78
- );
79
- }
80
- } catch (error: unknown) {
81
- const status = (error as { status?: number }).status;
82
- if (status) process.exit(status);
83
- throw error;
84
- }
37
+ delegateToAuraJsProjectCommand('make', parsed.passthrough);
85
38
  }
86
39
 
87
40
  main().catch((err) => {
@@ -406,7 +406,10 @@ export async function main(argv: string[] = process.argv.slice(2)) {
406
406
  });
407
407
  const env = buildPublishedGameLaunchEnv(
408
408
  process.env,
409
- plan.forwardedArgs[0] === 'join' ? { AURA_GAME_JOIN_MODE: 'play' } : {},
409
+ {
410
+ ...(plan.forwardedArgs[0] === 'join' ? { AURA_GAME_JOIN_MODE: 'play' } : {}),
411
+ AURAMAXX_CLI_AVAILABLE: '1',
412
+ },
410
413
  );
411
414
  progress.update(4, 'Launching game', plan.forwardedArgs[0] || 'play');
412
415
  execFileSync(process.execPath, [install.binAbsolutePath, ...plan.forwardedArgs], {
@@ -0,0 +1,84 @@
1
+ import { execFileSync } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const LIB_DIR = path.dirname(fileURLToPath(import.meta.url));
7
+ export const LOCAL_AURAJS_CLI = path.resolve(
8
+ LIB_DIR,
9
+ '../../../../../packages/aurascript/src/cli/src/cli.mjs',
10
+ );
11
+
12
+ export function resolveInvocationCwd(): string {
13
+ const forwardedCwd = process.env.AURA_INVOKE_CWD;
14
+ if (forwardedCwd && path.isAbsolute(forwardedCwd)) {
15
+ return forwardedCwd;
16
+ }
17
+
18
+ const shellPwd = process.env.PWD;
19
+ if (shellPwd && path.isAbsolute(shellPwd)) {
20
+ return shellPwd;
21
+ }
22
+
23
+ return process.cwd();
24
+ }
25
+
26
+ export function resolveAuraJsProjectRoot(startDir: string): string | null {
27
+ let current = path.resolve(startDir);
28
+
29
+ while (true) {
30
+ const auraConfigPath = path.join(current, 'aura.config.json');
31
+ const packageJsonPath = path.join(current, 'package.json');
32
+ if (existsSync(auraConfigPath) && existsSync(packageJsonPath)) {
33
+ return current;
34
+ }
35
+
36
+ const parent = path.dirname(current);
37
+ if (parent === current) break;
38
+ current = parent;
39
+ }
40
+
41
+ return null;
42
+ }
43
+
44
+ export function requireAuraJsProjectRoot(startDir: string): string {
45
+ const projectRoot = resolveAuraJsProjectRoot(startDir);
46
+ if (projectRoot) {
47
+ return projectRoot;
48
+ }
49
+
50
+ throw new Error('Not an AuraJS project. Run `auramaxx create my-game` first.');
51
+ }
52
+
53
+ export function delegateToAuraJsCommand(auraArgs: string[], cwd: string): never {
54
+ try {
55
+ if (existsSync(LOCAL_AURAJS_CLI)) {
56
+ execFileSync(process.execPath, [LOCAL_AURAJS_CLI, ...auraArgs], {
57
+ cwd,
58
+ stdio: 'inherit',
59
+ env: process.env,
60
+ });
61
+ } else {
62
+ execFileSync(
63
+ 'npm',
64
+ ['exec', '--yes', '--package', '@auraindustry/aurajs', '--', 'aura', ...auraArgs],
65
+ {
66
+ cwd,
67
+ stdio: 'inherit',
68
+ env: process.env,
69
+ },
70
+ );
71
+ }
72
+
73
+ process.exit(0);
74
+ } catch (error: unknown) {
75
+ const status = (error as { status?: number }).status;
76
+ process.exit(status || 1);
77
+ }
78
+ }
79
+
80
+ export function delegateToAuraJsProjectCommand(commandName: string, commandArgs: string[] = []): never {
81
+ const invocationCwd = resolveInvocationCwd();
82
+ const projectRoot = requireAuraJsProjectRoot(invocationCwd);
83
+ delegateToAuraJsCommand([commandName, ...commandArgs], projectRoot);
84
+ }