Skip to content

modifed action

modifed action #41

name: Run create-plugma on multiple OS
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: # Allows manual triggering
jobs:
test-cli:
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # Test on Ubuntu and Windows
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install create-plugma locally
run: |
npm install create-plugma@latest
- name: Write simulate-cli.js
run: |
echo "const { spawn } = require('child_process');" > simulate-cli.js
echo "(async () => {" >> simulate-cli.js
echo " try {" >> simulate-cli.js
echo " const cli = spawn('npx', ['create-plugma@latest'], { stdio: ['pipe', 'pipe', 'pipe'], shell: true });" >> simulate-cli.js
echo " cli.stdout.on('data', (data) => { console.log(\`STDOUT: \${data.toString()}\`); });" >> simulate-cli.js
echo " cli.stderr.on('data', (data) => { console.error(\`STDERR: \${data.toString()}\`); });" >> simulate-cli.js
echo " const responses = ['\\\\n', '\\\\n', 'TestProject\\\\n', '\\\\n'];" >> simulate-cli.js
echo " let index = 0;" >> simulate-cli.js
echo " cli.stdout.on('data', (data) => {" >> simulate-cli.js
echo " const output = data.toString();" >> simulate-cli.js
echo " console.log(\`Received: \${output}\`);" >> simulate-cli.js
echo " if (index < responses.length) { cli.stdin.write(responses[index]); index++; }" >> simulate-cli.js
echo " });" >> simulate-cli.js
echo " cli.on('close', (code) => {" >> simulate-cli.js
echo " console.log(\`CLI process exited with code: \${code}\`);" >> simulate-cli.js
echo " if (code !== 0) { process.exit(1); }" >> simulate-cli.js
echo " });" >> simulate-cli.js
echo " } catch (error) {" >> simulate-cli.js
echo " console.error('Error running create-plugma CLI:', error);" >> simulate-cli.js
echo " process.exit(1);" >> simulate-cli.js
echo " }" >> simulate-cli.js
echo "})();" >> simulate-cli.js
- name: Run simulate-cli.js
run: node simulate-cli.js
- name: Verify TestProject directory
run: |
if [ -d "TestProject" ]; then
echo "TestProject directory exists.";
else
echo "TestProject directory not found.";
exit 1;
fi
- name: Display package.json contents
run: |
echo "Contents of package.json:"
cat package.json || echo "Failed to read package.json"
working-directory: TestProject
- name: Install project dependencies
run: |
npm install
working-directory: TestProject
- name: Build the project
run: |
npm run build
working-directory: TestProject
- name: Verify Build
run: |
test -f dist/main.js && echo "Build succeeded" || (echo "Build failed" && exit 1)
working-directory: TestProject