@@ -113,13 +113,50 @@ async function executeExport(args) {
113113 if (!(__nccwpck_require__(9896).existsSync)(cliPath)) {
114114 throw new Error(`CLI library not found at ${cliPath}. Please run 'npm run build' in the main directory first.`);
115115 }
116- // We use a subprocess approach to call the CLI
116+ // Install CLI dependencies in the action's working directory
117+ core.info('Installing CLI dependencies...');
117118 const { spawn } = __nccwpck_require__(5317);
119+ // First, install the LiaScript exporter package globally to get all dependencies
120+ const installResult = await new Promise((resolve) => {
121+ const npmInstall = spawn('npm', ['install', '-g', '@liascript/exporter'], {
122+ stdio: ['pipe', 'pipe', 'pipe'],
123+ env: { ...process.env }
124+ });
125+ let installOutput = '';
126+ let installError = '';
127+ npmInstall.stdout.on('data', (data) => {
128+ installOutput += data.toString();
129+ core.info(`npm install: ${data.toString().trim()}`);
130+ });
131+ npmInstall.stderr.on('data', (data) => {
132+ installError += data.toString();
133+ core.warning(`npm install warning: ${data.toString().trim()}`);
134+ });
135+ npmInstall.on('close', (code) => {
136+ if (code === 0) {
137+ core.info('CLI dependencies installed successfully');
138+ resolve(true);
139+ }
140+ else {
141+ core.error(`Failed to install CLI dependencies: ${installError}`);
142+ resolve(false);
143+ }
144+ });
145+ npmInstall.on('error', (error) => {
146+ core.error(`Failed to start npm install: ${error.message}`);
147+ resolve(false);
148+ });
149+ });
150+ if (!installResult) {
151+ throw new Error('Failed to install CLI dependencies');
152+ }
153+ // Now use the globally installed CLI instead of the local one
154+ const globalCliCommand = 'liascript-exporter';
118155 // Build CLI arguments
119156 const cliArgs = buildCliArguments(args);
120157 core.info(`CLI arguments: ${cliArgs.join(' ')}`);
121158 return new Promise((resolve) => {
122- const childProcess = spawn('node', [cliPath, ... cliArgs] , {
159+ const childProcess = spawn(globalCliCommand, cliArgs, {
123160 cwd: args.path || path.dirname(args.input),
124161 stdio: ['pipe', 'pipe', 'pipe'],
125162 env: { ...process.env, NODE_ENV: 'production' }
@@ -199,7 +236,7 @@ async function executeExport(args) {
199236 childProcess.on('error', (error) => {
200237 clearTimeout(timeout);
201238 if (error.message.includes('ENOENT')) {
202- core.error(`Failed to start export process: Node.js not found or CLI path incorrect (${error.message})`);
239+ core.error(`Failed to start export process: CLI command not found (${error.message})`);
203240 }
204241 else {
205242 core.error(`Failed to start export process: ${error.message}`);
0 commit comments