react/packages/react-devtools-extensions/deploy.js
PrathamLalwani 2c338b16fd
Added windows powershell syntax to build scripts (#27692)
## Summary

I had to change the commands to be windows specific so that it doesn't
cause any crashes

## How did you test this change?

I successfully built the different types of devtools extenstions on my
personal computer. In future may need to add a github action with
windows config to test these errors

 #27193
2023-11-16 11:35:43 +00:00

52 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
'use strict';
const {exec, execSync} = require('child_process');
const {readFileSync, writeFileSync} = require('fs');
const {join} = require('path');
const shell = require('shelljs');
const main = async buildId => {
const root = join(__dirname, buildId);
const buildPath = join(root, 'build');
execSync(`node ${join(root, './build')}`, {
cwd: __dirname,
env: {
...process.env,
NODE_ENV: 'production',
},
stdio: 'inherit',
});
shell.cp(join(root, 'now.json'), join(buildPath, 'now.json'));
const file = readFileSync(join(root, 'now.json'));
const json = JSON.parse(file);
const alias = json.alias[0];
const commit = execSync('git rev-parse HEAD').toString().trim().slice(0, 7);
let date = new Date();
date = `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
const installationInstructions =
buildId === 'chrome'
? readFileSync(join(__dirname, 'deploy.chrome.html'))
: readFileSync(join(__dirname, 'deploy.firefox.html'));
let html = readFileSync(join(__dirname, 'deploy.html')).toString();
html = html.replace(/%commit%/g, commit);
html = html.replace(/%date%/g, date);
html = html.replace(/%installation%/, installationInstructions);
writeFileSync(join(buildPath, 'index.html'), html);
await exec(`now deploy && now alias ${alias}`, {
cwd: buildPath,
stdio: 'inherit',
});
console.log(`Deployed to https://${alias}.now.sh`);
};
module.exports = main;