auramaxx 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auramaxx",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "AuraJS CLI for creating, playing, and publishing JavaScript-first games.",
5
5
  "keywords": [
6
6
  "aurajs",
@@ -26,6 +26,8 @@
26
26
  "src/lib/startBannerQuotes.ts",
27
27
  "src/server/cli/commands/onboard.ts",
28
28
  "src/server/cli/commands/create.ts",
29
+ "src/server/cli/commands/fork.ts",
30
+ "src/server/cli/commands/make.ts",
29
31
  "src/server/cli/commands/play.ts",
30
32
  "src/server/cli/commands/publish.ts",
31
33
  "src/server/cli/lib/published-game-integrity.ts",
@@ -0,0 +1,81 @@
1
+ import { execFileSync } from 'child_process';
2
+ import { rmSync } from 'fs';
3
+ import { pathToFileURL } from 'url';
4
+
5
+ import { printBanner, printSection, paint, ANSI } from '../lib/theme';
6
+ import {
7
+ buildPublishedGameLaunchEnv,
8
+ installVerifiedGamePackage,
9
+ parseArgs,
10
+ resolveGameBin,
11
+ resolvePackageName,
12
+ } from './play';
13
+
14
+ export interface ForkCommandPlan {
15
+ help: boolean;
16
+ name: string | null;
17
+ gameArgs: string[];
18
+ gameBin: string | null;
19
+ packageName: string | null;
20
+ forwardedArgs: string[];
21
+ }
22
+
23
+ export function buildForkPlan(argv: string[]): ForkCommandPlan {
24
+ const parsed = parseArgs(argv);
25
+ return {
26
+ ...parsed,
27
+ gameBin: parsed.name ? resolveGameBin(parsed.name) : null,
28
+ packageName: parsed.name ? resolvePackageName(parsed.name) : null,
29
+ forwardedArgs: ['fork', ...parsed.gameArgs],
30
+ };
31
+ }
32
+
33
+ export async function main(argv: string[] = process.argv.slice(2)) {
34
+ const plan = buildForkPlan(argv);
35
+
36
+ if (plan.help || !plan.name) {
37
+ printBanner('FORK');
38
+ console.log(` ${paint('Usage:', ANSI.bold)} auramaxx fork <game> [destination|wrapper fork options]`);
39
+ console.log('');
40
+ console.log(` ${paint('Examples:', ANSI.dim)}`);
41
+ console.log(' auramaxx fork aurasu');
42
+ console.log(' auramaxx fork aurasu ./aurasu-local');
43
+ console.log(' auramaxx fork @auraindustry/chess-dev-cli@1.2.3 --dest ./chess-local');
44
+ console.log('');
45
+ console.log(` ${paint('Runs:', ANSI.dim)} verified signed temporary install -> local game wrapper fork`);
46
+ console.log('');
47
+ if (!plan.name && !plan.help) {
48
+ console.error(' Missing game name.');
49
+ process.exit(1);
50
+ }
51
+ return;
52
+ }
53
+
54
+ printBanner(plan.name.toUpperCase());
55
+ printSection(plan.name, 'Forking editable package into local project...');
56
+
57
+ let install: Awaited<ReturnType<typeof installVerifiedGamePackage>> | null = null;
58
+ try {
59
+ install = await installVerifiedGamePackage(plan);
60
+ const env = buildPublishedGameLaunchEnv(process.env);
61
+ execFileSync(process.execPath, [install.binAbsolutePath, ...plan.forwardedArgs], {
62
+ stdio: 'inherit',
63
+ cwd: install.packageRoot,
64
+ env,
65
+ });
66
+ } finally {
67
+ if (install?.installRoot) {
68
+ rmSync(install.installRoot, { recursive: true, force: true });
69
+ }
70
+ }
71
+ }
72
+
73
+ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
74
+ main().catch((err) => {
75
+ console.error(err instanceof Error ? err.message : String(err));
76
+ const status = (err as { status?: number; exitCode?: number })?.status
77
+ ?? (err as { status?: number; exitCode?: number })?.exitCode
78
+ ?? 1;
79
+ process.exit(Number.isInteger(status) ? status : 1);
80
+ });
81
+ }
@@ -0,0 +1,90 @@
1
+ import { execFileSync } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ 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
+ );
12
+
13
+ function parseArgs(argv: string[]) {
14
+ for (const arg of argv) {
15
+ if (arg === '--help' || arg === '-h') {
16
+ return { help: true, passthrough: [] as string[] };
17
+ }
18
+ }
19
+ return {
20
+ help: false,
21
+ passthrough: [...argv],
22
+ };
23
+ }
24
+
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
+ async function main() {
39
+ const parsed = parseArgs(process.argv.slice(2));
40
+
41
+ if (parsed.help) {
42
+ printBanner('MAKE');
43
+ console.log(` ${paint('Usage:', ANSI.bold)} auramaxx make [kind] [name] [--role <custom|enemy|pickup|player|world>]`);
44
+ console.log('');
45
+ console.log(' Public wrapper around AuraJS project file generation.');
46
+ console.log(' Run it from inside an AuraJS game project.');
47
+ console.log(` ${paint('Examples:', ANSI.dim)}`);
48
+ console.log(' auramaxx make');
49
+ console.log(' auramaxx make scene Scene1');
50
+ console.log(' auramaxx make ui-screen PauseMenu');
51
+ console.log(' auramaxx make prefab EnemyShip --role enemy');
52
+ console.log(' auramaxx make list');
53
+ console.log('');
54
+ console.log(' When no arguments are passed in a TTY, AuraJS opens an interactive make flow.');
55
+ console.log('');
56
+ return;
57
+ }
58
+
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
+ }
85
+ }
86
+
87
+ main().catch((err) => {
88
+ console.error(err instanceof Error ? err.message : String(err));
89
+ process.exit(1);
90
+ });
@@ -114,6 +114,27 @@ function resolveAuramaxxCommand(): string {
114
114
  return process.platform === 'win32' ? 'auramaxx.cmd' : 'auramaxx';
115
115
  }
116
116
 
117
+ function resolveInstalledGlobalAuramaxxVersion(): string | null {
118
+ try {
119
+ const root = execFileSync(resolveNpmCommand(), ['root', '-g'], {
120
+ stdio: ['ignore', 'pipe', 'pipe'],
121
+ encoding: 'utf8',
122
+ timeout: 30000,
123
+ }).trim();
124
+ if (!root) {
125
+ return null;
126
+ }
127
+ const packageJsonPath = join(root, 'auramaxx', 'package.json');
128
+ if (!existsSync(packageJsonPath)) {
129
+ return null;
130
+ }
131
+ const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as { version?: unknown };
132
+ return typeof pkg.version === 'string' && pkg.version.trim().length > 0 ? pkg.version.trim() : null;
133
+ } catch {
134
+ return null;
135
+ }
136
+ }
137
+
117
138
  function normalizeRelativePath(pathLike: string): string {
118
139
  return String(pathLike || '')
119
140
  .trim()
@@ -212,12 +233,26 @@ async function promptUpgradeAuramaxx(expectedAurajsVersion: string): Promise<boo
212
233
 
213
234
  function installLatestAuramaxx(): void {
214
235
  console.log('');
215
- console.log(` ${paint('Installing latest AuraMaxx...', ANSI.bold)}`);
236
+ console.log(` ${paint('Reinstalling latest AuraMaxx...', ANSI.bold)}`);
216
237
  console.log('');
238
+ try {
239
+ execFileSync(resolveNpmCommand(), ['uninstall', '-g', 'auramaxx'], {
240
+ stdio: 'inherit',
241
+ timeout: 120000,
242
+ });
243
+ } catch {
244
+ // Ignore missing-package uninstall failures and continue with a clean install.
245
+ }
217
246
  execFileSync(resolveNpmCommand(), ['install', '-g', 'auramaxx@latest', '--foreground-scripts'], {
218
247
  stdio: 'inherit',
219
- timeout: 120000,
248
+ timeout: 180000,
220
249
  });
250
+
251
+ const installedVersion = resolveInstalledGlobalAuramaxxVersion();
252
+ if (installedVersion) {
253
+ console.log('');
254
+ console.log(` ${paint(`Installed AuraMaxx ${installedVersion}`, ANSI.dim)}`);
255
+ }
221
256
  }
222
257
 
223
258
  function relaunchWithUpdatedAuramaxx(argv: string[]): never {
@@ -400,7 +435,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
400
435
  ? updateError.message
401
436
  : String(updateError),
402
437
  );
403
- console.error(' Manual fallback: npm install -g auramaxx@latest');
438
+ console.error(' Manual fallback: npm uninstall -g auramaxx && npm install -g auramaxx@latest');
404
439
  process.exit(1);
405
440
  }
406
441
  })().catch((promptError) => {